home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_091 / man / adl.doc < prev    next >
Text File  |  1992-05-06  |  114KB  |  5,413 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.        The ADL Programmer's    Reference Manual
  11.  
  12.  
  13.             Tim Brengle
  14.             Ross Cunniff
  15.  
  16.           Hewlett-Packard Company
  17.         Cupertino, California 95014
  18.  
  19.  
  20.  
  21.               ABSTRACT
  22.  
  23.       ADL (which stands for     "Adventure  Definition
  24.      Language")     is a programming language and run-time
  25.      environment designed for the convenient  implemen-
  26.      tation  of     Adventure-like     games.      This document
  27.      describes ADL and is intended for    the  use  of  a
  28.      programmer    who wishes to create such a game.
  29.  
  30.       The authors would  like  to  acknowledge  the
  31.      tremendous     influence  of the earlier language DDL
  32.      from which    ADL was    derived.  DDL  was  created  in
  33.      1981  by  Bruce  Adler,  Chris  Kostanick,    Michael
  34.      Stein,  Michael  Urban,  and  Warren  Usui,   then
  35.      members  of  the UCLA Computer Club.  For informa-
  36.      tion on DDL, please consult the document "A  Brief
  37.      Description  of  UCLA  Dungeon Definition Language
  38.      (DDL)" written by the creators of DDL  and     avail-
  39.      able from the University of California.
  40.  
  41.  
  42.  
  43. June 19, 1987
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.         c 1987 Ross    Cunniff    and Tim    Brengle
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.        The ADL Programmer's    Reference Manual
  143.  
  144.  
  145.             Tim Brengle
  146.             Ross Cunniff
  147.  
  148.           Hewlett-Packard Company
  149.         Cupertino, California 95014
  150.  
  151.  
  152.  
  153. 1.  Introduction
  154.  
  155.      Computer games have existed for nearly as long as    com-
  156. puters    have existed.  One of the most popular computer    pro-
  157. grams of all time is Adventure.     In Adventure, the player is
  158. placed inside a    world which exists only    in the memory of the
  159. computer (and the mind of the player).    The player interacts
  160. with this world    by means of English-like sentences.  Objects
  161. that the player    finds may be taken, opened, closed,  tasted,
  162. thrown,    and otherwise manipulated.
  163.  
  164.      Previously, most programmers attempting to    write  their
  165. own  Adventure-like  game  have     been  bogged  down  by    such
  166. trivial    details    as implementing    a parser for  player  input,
  167. properly  responding  to  the player's commands, and dealing
  168. with the passage of time.  ADL is intended  to    relieve     the
  169. programmer  of    such  worries and to allow the programmer to
  170. concentrate on the important details of    the imaginary world.
  171. The  following    is  a  short excerpt from the play of a    game
  172. which was written in ADL:
  173.  
  174.      Red room.
  175.      You are in    a large    room which is illuminated by a bright red glow.
  176.      Exits lie to the east and south.
  177.      > Go east.
  178.      Green room.
  179.      You are in    a smallish room    which is illuminated by    a pleasant green
  180.      glow.  The    only exit is to    the west.
  181.        There is    a robot    here.
  182.      > west
  183.      Red room.
  184.      > s
  185.      Blue room.
  186.      You are in    a tiny room which is barely illuminated    by a dim blue
  187.      glow.  There is an    exit to    the north, and you seem    to make    out
  188.      something on the floor.  There is a button    on the wall.  Above the
  189.      button is a sign that reads:
  190.  
  191.              DANGER!
  192.  
  193.  
  194.  
  195.  
  196.         c 1987 Ross    Cunniff    and Tim    Brengle
  197.  
  198.  
  199.  
  200.  
  201.  
  202.                - 2 -
  203.  
  204.  
  205.           HIGH VOLTAGE!
  206.  
  207.      > n
  208.      Red room.
  209.      > e
  210.      Green room.
  211.      You can see:
  212.        a robot
  213.      > Tell the    robot "Go west then south.  Push the button then go north."
  214.      "Sure thing, Boss."
  215.      The robot exits to    the west.
  216.  
  217.      Notice that this script demonstrates powerful  features
  218. not  present in    many other Adventure-like games.  This docu-
  219. ment will describe the utilities and "tricks"  necessary  to
  220. write games such as the    above.
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.         c 1987 Ross    Cunniff    and Tim    Brengle
  263.  
  264.  
  265.  
  266.  
  267.  
  268.                - 3 -
  269.  
  270.  
  271. 2.  ADL    Data types
  272.  
  273.      Structured    data types are the heart of  any  structured
  274. language.   ADL    is not lacking in structured data types.  It
  275. is through the proper definition of  specific  instances  of
  276. these data types that the ADL programmer defines a scenario.
  277. Note that all data types in ADL    are represented    by  sixteen-
  278. bit integer IDs.  Although there is little facility for    pro-
  279. ducing user-defined data types,    the power  of  the  existing
  280. set  makes  it    unlikely that such would be required for any
  281. reasonable scenario.
  282.  
  283. 2.1.  Objects
  284.  
  285.      As    in most    Adventure-like    games,    the  most  important
  286. data  type in ADL is the Object.  An object in real life can
  287. be a person, place, or thing.  ADL models the world  in     the
  288. same   way.    Any  Object  encountered     by  the  player  is
  289. represented by this  type,  as    are  all  locations  in     the
  290. scenario.  Indeed, there can be    Objects    associated with    peo-
  291. ple (more on  that  later).   Notice  that  ADL     treats     all
  292. Objects     uniformly and so it is    possible to write a scenario
  293. in which a player picks    up an Object (a    tent, say),  carries
  294. it around, and later enters it.
  295.  
  296.      All Objects are  represented  by  (unique)     sixteen-bit
  297. integers.   This  number  is known as the "Object ID" of the
  298. Object.     Objects are (essentially)  record  structures    with
  299. the following elements:
  300.  
  301. Location      The Object ID of    the  Object  which  contains
  302.           this Object.
  303.  
  304. Contents      The Object ID of the  first  Object  which  is
  305.           contained     in this Object, or zero if there is
  306.           no such Object.
  307.  
  308. Link          The Object ID of    the  next  Object  which  is
  309.           located  in  the    same place as this Object or
  310.           zero if there is no such Object.
  311.  
  312. Modifier      The ID of    the modifier of    this Object or    zero
  313.           if  the  Object has no modifier.    For example,
  314.           the Object "blue streak" would have a modifier
  315.           ID  which     is the    adjective "blue".  Modifiers
  316.           are explained further in Section 2.9.
  317.  
  318. Properties    Associated with each Object are 32 properties.
  319.           While all    of the above elements are maintained
  320.           directly or indirectly by    the ADL    system,     the
  321.           values  and  meanings  of     properties  are the
  322.           responsibility of    the programmer.      The  first
  323.           16 of these properties may only hold the value
  324.           0     or  1    (hence    they  are   usually   called
  325.  
  326.  
  327.  
  328.         c 1987 Ross    Cunniff    and Tim    Brengle
  329.  
  330.  
  331.  
  332.  
  333.  
  334.                - 4 -
  335.  
  336.  
  337.           "boolean"     properties).  Properties 17 through
  338.           32 may  hold  any     value    between     -32768     and
  339.           32767.   The  last  three     of these properties
  340.           have special meaning to ADL:
  341.  
  342.           LDESC  (30)   This is  the  ID  of  a  routine
  343.                 which  prints  a "long" descrip-
  344.                 tion of  the  Object.   Routines
  345.                 are    defined    in Chapter 6.
  346.  
  347.           SDESC  (31)   This is  the  ID  of  a  routine
  348.                 which  prints a "short" descrip-
  349.                 tion of the    Object.
  350.  
  351.           ACTION (32)   This is  the  ID  of  a  routine
  352.                 which  is  called under the    cir-
  353.                 cumstances detailed     in  Chapter
  354.                 4.
  355.  
  356.      All Objects in ADL    are stored in a    tree.  The root    node
  357. of  the    tree is    predeclared and    is named ".ALL".  Its Object
  358. ID is always zero.  All    other Objects are ultimately located
  359. in .ALL.
  360.  
  361.      Two other predeclared  Objects  exist.   One  is  named
  362. "STRING"  and the other    is named ".ME".     .ME is    not truly an
  363. Object -- it is    more like a variable  which  represents     the
  364. current     Actor    during the execution of    an ADL program (more
  365. on Actors in Section 3.1).  It is illegal to use .ME outside
  366. of  the    context    of a routine.  STRING is the Object which is
  367. seen by    the ADL    program    when the  run-time  sentence  parser
  368. encounters  a  string.     Note that although STRING is prede-
  369. clared by ADL, the properties of STRING    must be     defined  by
  370. the  ADL  programmer.  See Chapter 9 for more information on
  371. STRING.
  372.  
  373. 2.2.  Verbs
  374.  
  375.      Verbs are the means whereby a  player  manipulates     the
  376. environment.   Verbs can denote    motion,    investigation, mani-
  377. pulation, and any other    action the ADL programmer  can    ima-
  378. gine.    A Verb is represented by a sixteen-bit integer known
  379. as the Verb ID.     Like Objects, Verbs are record     structures.
  380. They have the following    elements:
  381.  
  382. PREACT          The ID of    a routine to  be  called  when    this
  383.           Verb  is    typed by the player.  The routine is
  384.           called  before  the  ACTION  routines  of     the
  385.           Objects  in  the    sentence.  See Chapter 4 for
  386.           more information.
  387.  
  388. ACTION          The ID of    a routine to  be  called  when    this
  389.           Verb  is typed by    the player.  This routine is
  390.           called  after  the  ACTION  routines  of     the
  391.  
  392.  
  393.  
  394.         c 1987 Ross    Cunniff    and Tim    Brengle
  395.  
  396.  
  397.  
  398.  
  399.  
  400.                - 5 -
  401.  
  402.  
  403.           Objects in the sentence.    Again, see Chapter 4
  404.           for more information.
  405.  
  406.      Verbs may also be used as modifiers to nouns.  This  is
  407. to  allow  easy     implementation     of  Objects like the "north
  408. wall" or "go north" (where "north" is  normally     a  verb  of
  409. motion).
  410.  
  411.      ADL predeclares the two  Verbs  "TELLER"  and  "NOVERB"
  412. which  are  returned by    the parser under circumstances shown
  413. in Chapter 9.  Although    TELLER and NOVERB  are    predeclared,
  414. their properties must be defined by the    ADL programmer.
  415.  
  416. 2.3.  Adjectives
  417.  
  418.      Adjectives    serve only one purpose:    to disambiguate    oth-
  419. erwise    identical  nouns  (such     as a "red ball" and a "blue
  420. ball").     Adjectives have no  structure    and  exist  only  as
  421. sixteen-bit Adjective IDs.
  422.  
  423. 2.4.  Strings
  424.  
  425.      There are two forms of strings  in     ADL:    compile-time
  426. strings     and  run-time    strings.   Compile-time     strings are
  427. those which appear in the ADL source code for the  scenario.
  428. They are delimited by double quotes and    are transformed    into
  429. positive sixteen-bit String  IDs  by  the  compiler.   These
  430. strings     are  free-form    in that    a carriage return may appear
  431. in them    at any point.    This  sort  of    carriage  return  is
  432. transformed  into a blank.  Should the ADL programmer desire
  433. a true carriage    return,    the sequence \n    should    be  embedded
  434. in  the     string     at  the  appropriate  point.    Compile-time
  435. strings    may be limited to 255 characters in length  in    some
  436. implementations.
  437.  
  438.      Run-time strings are  those  which     are  typed  by     the
  439. player    and those which    are generated by the built-in string
  440. manipulation routines.    Strings    in player input    may be    del-
  441. imited by appropriately    nested single or double    quotes.     All
  442. run-time strings are  represented  as  NEGATIVE     sixteen-bit
  443. string IDs.
  444.  
  445. 2.5.  Numbers
  446.  
  447.      There are two forms of numbers  in     ADL:    compile-time
  448. numbers    and run-time numbers.  Compile-time numbers exist in
  449. the ADL    source code for    the scenario and may be    any  integer
  450. in the range of    -32768 to 32767    inclusive.  Run-time numbers
  451. are those which    are typed by the player.   Run-time  numbers
  452. are  transformed  into    a  string  consisting  of  the ASCII
  453. representation of their    digits.     A  negative  string  ID  is
  454. then returned for eventual use by the ADL program.
  455.  
  456.  
  457.  
  458.  
  459.  
  460.         c 1987 Ross    Cunniff    and Tim    Brengle
  461.  
  462.  
  463.  
  464.  
  465.  
  466.                - 6 -
  467.  
  468.  
  469. 2.6.  Routines
  470.  
  471.      Routines in ADL are represented by    (what else?) sixteen
  472. bit  Routine  IDs.   The only operations allowed on routines
  473. are calling them and  passing  them  to     other    routines  as
  474. parameters.   The  syntax  of  ADL  routines is    described in
  475. Chapter    6.  The    routine    "START"    is predeclared    by  ADL     and
  476. must  be  defined  by  the  programmer    or execution will be
  477. prematurely terminated.     The Routines  "DWIMI"    and  "DWIMD"
  478. are  also  predeclared    by  ADL    and should be defined by the
  479. programmer.  DWIMI and DWIMD are called    under  circumstances
  480. detailed in Chapter 4.
  481.  
  482. 2.7.  Global Variables
  483.  
  484.      There are a number    of global  variables  available     for
  485. definition  and     use  by  the  ADL  programmer.     A global is
  486. represented by a sixteen-bit ID    and  may  hold    any  integer
  487. value from -32768 to 32767.  These values may be interpreted
  488. as simple numbers, String IDs, Routine IDs, Object IDs,    Verb
  489. IDs,  etc.  depending  upon  how they are used.     The globals
  490. named Verb, Conj, Numd,    Dobj, Prep, and    Iobj are predeclared
  491. by  ADL     and  at  run-time contain the values of the current
  492. Verb, Conjunction, Number of Direct Objects, Direct  Object,
  493. Preposition, and Indirect Object, respectively.
  494.  
  495.      The ADL programmer    may declare a block of global  vari-
  496. ables  for use as an array or list of things.  See Chapter 5
  497. for more information.
  498.  
  499. 2.8.  Local variables
  500.  
  501.      Local variables differ from global     variables  in    that
  502. their  name is limited in scope    to the routine in which    they
  503. appear.     They are represented by sixteen-bit IDs  which     may
  504. be passed to other routines if desired.     Local variables may
  505. be implemented in one of two ways: on the stack    (like  local
  506. variables  on  C  and  Pascal)    in  which case they are    only
  507. around for as long as the current invocation of    the routine;
  508. or  they  may  reside  in the same space as global variables
  509. (like static locals in C or local variables in    FORTRAN)  in
  510. which  case  they persist for the entire duration of program
  511. execution.  Consult your local ADL documentation  to  deter-
  512. mine which method is used in your implementation.
  513.  
  514. 2.9.  Modifiers
  515.  
  516.      A modifier    is simply a word that modifies an  ambiguous
  517. noun  to produce an Object.  A modifier    may be either a    Verb
  518. or an Adjective.  If the modifier of an    Object is a Verb, it
  519. is  represented    as the NEGATIVE    of the Verb ID.     If it is an
  520. Adjective it is    represented by the (positive) Adjective     ID.
  521. If the modifier    is zero, the Object has    no modifier.
  522.  
  523.  
  524.  
  525.  
  526.         c 1987 Ross    Cunniff    and Tim    Brengle
  527.  
  528.  
  529.  
  530.  
  531.  
  532.                - 7 -
  533.  
  534.  
  535. 3.  ADL    Internal Structures
  536.  
  537.      ADL maintains several internal  structures     to  achieve
  538. the  level  of    interaction  necessary for interesting play.
  539. These structures are accessible    only  through  the  built-in
  540. routines described in Chapter 7.
  541.  
  542. 3.1.  Actors
  543.  
  544.      In    a typical adventure game it seems as if     the  player
  545. is  moving  around the dungeon taking things, smelling them,
  546. breaking them, and so on.  A better model would    be that     the
  547. player    is  giving  commands  to  an actor.  It    is the actor
  548. which actually moves around, collects items,  and  otherwise
  549. acts.  It is this model    which ADL follows.
  550.  
  551.      An    Actor is essentially an    "animate" object which    acts
  552. upon  commands given to    it.  Notice that there is nothing in
  553. this model which prevents more than one    Actor  from  running
  554. around    a  scenario.  In fact, in ADL there may    be up to ten
  555. Actors which are active    at any one time.
  556.  
  557.      There are two kinds of Actors:   interactive  and    non-
  558. interactive.   The  player  is    an example of an interactive
  559. Actor.    Commands are read directly  from  the  keyboard     and
  560. placed    in  a line buffer which    is then    passed to the parser
  561. and interpreter.  When the line    buffer is empty    a new one is
  562. read  from  the     keyboard.   Any  number  of  Actors  may be
  563. interactive, making multiple player games a possibility.
  564.  
  565.      The robot in the introductory script is an    example    of a
  566. non-interactive     Actor (see Appendix 2 for the source to the
  567. scenario which produced    that script).  The line     buffer     for
  568. the  robot  was     initialized after the player typed the    sen-
  569. tence starting with "Tell the robot ...".   The     robot    then
  570. acted on this command by performing the    requested actions in
  571. parallel with the actions of the player.   This     means    that
  572. each  Actor  gets  one    turn  for  each    turn that the player
  573. experiences.  A    non-interactive    Actor is  deleted  from     the
  574. list of    active Actors when its line buffer is emptied.
  575.  
  576.      There is a    special    object-like item named ".ME" used to
  577. implement  this     sort  of "multiprocessing".  .ME represents
  578. the Object ID of the current Actor for the purposes of    mov-
  579. ing  around,  taking  things, etc.  Anything that the player
  580. can do can be done just    as well    by another Actor.   This  is
  581. probably  the  most  powerful  (and most obscure) feature of
  582. ADL.
  583.  
  584.      Actors may    be activated using the $actor built-in    rou-
  585. tine and deleted at any    time by    using the $delact routine.
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.         c 1987 Ross    Cunniff    and Tim    Brengle
  593.  
  594.  
  595.  
  596.  
  597.  
  598.                - 8 -
  599.  
  600.  
  601. 3.2.  Daemons
  602.  
  603.      Daemons are routines which    execute    once for each active
  604. Actor  at the beginning    of each    turn.  Daemons are typically
  605. used for things    like describing    the  player's  location     and
  606. incrementing  the  turn     counter.   Daemons are    activated by
  607. using the $sdem    routine    and may    be de-activated    by using the
  608. $ddem routine.    Up to ten daemons may be active    at one time.
  609.  
  610. 3.3.  Fuses
  611.  
  612.      Fuses are routines    which wait a certain amount of time,
  613. execute,  then    become inactive.  The list of fuses is exam-
  614. ined each time    the  turn  counter  is    incremented  to     see
  615. whether    any have "burned down".     If so,    the fuse is executed
  616. and deleted from the list.
  617.  
  618.      Fuses are typically used for things like waiting  three
  619. turns  and  then collapsing the    room that the player was in,
  620. or (the    bane of    all adventurers) running down the  batteries
  621. in  a lamp.  Fuses are activated by using the $sfus routine.
  622. Up to ten fuses    may be active at one time.  The     $dfus    rou-
  623. tine may be called if the programmer wishes to delete a    fuse
  624. before it executes (the    player found more batteries!).
  625.  
  626. 3.4.  Prompter
  627.  
  628.      Many times    during the play    of the game  it     is  desired
  629. that  a    player enter a line from the keyboard.    Some sort of
  630. prompting should be done in order to inform the    player    that
  631. input  is desired.  The    ADL programmer may specify a Routine
  632. ID to do this prompting.   This     routine  is  known  as     the
  633. prompter and is    set by using the $prompt routine.
  634.  
  635. 3.5.  Run-Time Macros
  636.  
  637.      Normally when the parser gets its input from  the    line
  638. buffer of the current Actor, the words are what    they seem to
  639. be:  simple words.  ADL    has a facility whereby    these  words
  640. may  be     transformed before the    parser sees them.  Each    word
  641. is looked up in    a table    (the "macro table").  If found it is
  642. replaced  by  the  expansion  for  the macro (which may    be a
  643. string containing more than one    word) and  re-inserted    into
  644. the line buffer    whereupon the input process continues.
  645.  
  646.      One use of    this facility is to "rename"  objects.     For
  647. example,  it  may be desired that the player be    able to    type
  648. something like "Name the box 'bob'.  Take bob."    (notice    that
  649. the  second usage of bob has no    quotes).  This can be accom-
  650. plished    by the call ($define  "bob"  "box")  which  says  to
  651. expand "bob" to    "box" whenever it is encountered in the    line
  652. buffer.     The built-in routine $undef may be used  to  "unde-
  653. fine"  a  macro    if it outlives its usefulness -- for example
  654. ($undef    "bob") removes "bob" from the macro table.  More  is
  655.  
  656.  
  657.  
  658.         c 1987 Ross    Cunniff    and Tim    Brengle
  659.  
  660.  
  661.  
  662.  
  663.  
  664.                - 9 -
  665.  
  666.  
  667. said  about  macros  in     Section  7.10 under the entries for
  668. $define    and $undef.
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.         c 1987 Ross    Cunniff    and Tim    Brengle
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                - 10    -
  731.  
  732.  
  733. 4.  Putting It All Together
  734.  
  735.      The flow of execution of the game can be described     now
  736. that  the basic    data types have    been defined.  The execution
  737. starts with an initialization step:  an     ADL  routine  named
  738. START  is  called.   ADL terminates prematurely    if START has
  739. not been defined.  START typically activates  the  principal
  740. Actor  (the  player)  and  a  looker daemon (responsible for
  741. describing  the     player's  surroundings),  initializes     the
  742. prompter,  and    so on.    ADL then enters    a loop from which it
  743. never returns (until program termination).
  744.  
  745. 4.1.  The Flow of Execution
  746.  
  747.      The main loop of the  game     consists  of  a  series  of
  748. phases.      The built-in routine $phase will return the number
  749. of the phase currently executing (see the flow    diagram     and
  750. Section     7.12 for the number of    each of    the phases).  At the
  751. beginning of each turn,    all active Daemons are executed     for
  752. each  Actor  on     the  Actor  list -- in    the REVERSE order in
  753. which the Actors were activated.  This is so newly activated
  754. Actors    don't  act  before the older Actors have a chance to
  755. act.  The Daemons are executed in the order  in     which    they
  756. were activated.
  757.  
  758.      After all Daemons    have  executed    for  all  Actors,  a
  759. series    of  phases  are    executed for each Actor    on the Actor
  760. list (in the reverse order of Actor activation).   The    loop
  761. progresses downward in an orderly fashion unless interrupted
  762. by a call to $exit.  For information on     $exit    see  Section
  763. 4.2.   The  following  are the phases which are    executed for
  764. each Actor on the Actor    list:
  765.  
  766. Clear Sentence      The global  variables     Verb,    Conj,  Numd,
  767.           Dobj,     Prep,    and Iobj are set to 0.    This
  768.           is done in a separate    phase to  facilitate
  769.           the  implementation  of  incremental    sen-
  770.           tences such as "Take.     The red ball."
  771.  
  772. Input          A new    line buffer is prompted    for and    read
  773.           if  the  line     buffer     is  empty  and     the
  774.           current Actor    is interactive.
  775.  
  776.           The current  Actor  is  deleted  from     the
  777.           Actor     list and execution continues start-
  778.           ing with the next Actor if the line buffer
  779.           is  empty  and  the  current    Actor is NOT
  780.           interactive.
  781.  
  782. Parse          All upper case letters in the    line  buffer
  783.           are  transformed  into lower case letters.
  784.           An attempt is    then  made  at    parsing     the
  785.           line buffer into a Verb, Direct Objects, a
  786.           Preposition, and an Indirect Object.    Note
  787.  
  788.  
  789.  
  790.         c 1987 Ross    Cunniff    and Tim    Brengle
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                - 11    -
  797.  
  798.  
  799.           that    unambiguous  abbreviations  of words
  800.           are recognized by the    parser (for example,
  801.           if the words "newt" and "newspaper" are in
  802.           the vocabulary,  "new"  is  ambiguous     but
  803.           "news" is an abbreviation of "newspaper").
  804.           An appropriate message is printed if    this
  805.           does    not  succeed and execution continues
  806.           from the Input phase.
  807.  
  808.           ADL sentences    are typically  of  the    form
  809.           "Verb      DobjList  Prep  Iobj"     "Verb    Iobj
  810.           DobjList", or    "Iobj, String".     This is  an
  811.           overly simplistic description    - for a    full
  812.           specification    see Chapter 9.
  813.  
  814. DWIM          An object may    be ambiguous either  through
  815.           the  lack of a modifier or through the use
  816.           of a modifier    without    a noun (e.g.  typing
  817.           "Take     the ball" when    there is both a    "red
  818.           ball"    and a "blue ball", or  typing  "Take
  819.           red" in the same situation).
  820.  
  821.           An ADL routine named "DWIMI"    is  used  if
  822.           the  Indirect     Object    is ambiguous.  DWIMI
  823.           is called once for each Object that  could
  824.           possibly  be    the one    meant by the player.
  825.           If EXACTLY one of these  calls  returns  a
  826.           non-zero   value  then  the  corresponding
  827.           Object becomes the Indirect Object.    How-
  828.           ever,     if  DWIMI  never returns a non-zero
  829.           value    or if it returns  a  non-zero  value
  830.           more    than  once, the    player is told to be
  831.           more    specific  and  execution   continues
  832.           starting  with  the  Clear  Sentence phase
  833.           above.
  834.  
  835.           An ADL routine named "DWIMD"    is  used  if
  836.           any  of  the Direct Objects are ambiguous.
  837.           DWIMD    is called for the Objects  in  ques-
  838.           tion just like DWIMI.
  839.  
  840. Execution      The  following  phases  are  executed     for
  841.           every     Direct     Object    in the Direct Object
  842.           list.     They are executed exactly  once  if
  843.           there    are no Direct Objects.    This loop is
  844.           the heart of the ADL system and  is  where
  845.           the player's commands    are actually carried
  846.           out.
  847.  
  848.           Actor    ACTION        The     ACTION     routine  of
  849.                     the      current  Actor  is
  850.                     executed.  It  typically
  851.                     checks  the    sentence and
  852.                     possibly  modifies     it.
  853.  
  854.  
  855.  
  856.         c 1987 Ross    Cunniff    and Tim    Brengle
  857.  
  858.  
  859.  
  860.  
  861.  
  862.                - 12    -
  863.  
  864.  
  865.                     This allows    the handling
  866.                     of cases like "Take     the
  867.                     beer   then      drink     it"
  868.                     (where "it"    needs to  be
  869.                     massaged to    mean "beer")
  870.                     and    "Go north.   Again."
  871.                     (where  "Again" needs to
  872.                     be transformed into     "Go
  873.                     north").
  874.  
  875.           Verb PREACT        The     PREACT     routine  of
  876.                     the    current    Verb is    exe-
  877.                     cuted.    It   typically
  878.                     guards against incorrect
  879.                     use    of  multiple  Direct
  880.                     Objects,  or  the use of
  881.                     Indirect   Objects      or
  882.                     strings  where  such use
  883.                     doesn't make sense.      It
  884.                     also  might     check    that
  885.                     all     objects  named     are
  886.                     available for use.
  887.  
  888.           Iobj ACTION        The     ACTION     routine  of
  889.                     the      current   Indirect
  890.                     Object   is       executed.
  891.                     This   is    where    some
  892.                     object-specific  actions
  893.                     are       performed.     For
  894.                     example,  the   sentence
  895.                     "Put  the  coins  in the
  896.                     slot" might     be  handled
  897.                     here  if  putting  coins
  898.                     into   the     slot     (as
  899.                     opposed  to     a  box    or a
  900.                     bag)  causes   something
  901.                     special  to     happen.  If
  902.                     the    Indirect Object    is a
  903.                     string  then  the ACTION
  904.                     routine  of     the  prede-
  905.                     clared  ADL    Object named
  906.                     STRING is executed.
  907.  
  908.           Dobj ACTION        The     ACTION     routine  of
  909.                     the       current    Direct
  910.                     Object   is       executed.
  911.                     This   is    where    most
  912.                     object-specific  actions
  913.                     are       performed.     For
  914.                     example,  the   sentence
  915.                     "Rub  the lamp" might be
  916.                     handled here if  rubbing
  917.                     the     lamp  is  different
  918.                     than rubbing  any  other
  919.  
  920.  
  921.  
  922.         c 1987 Ross    Cunniff    and Tim    Brengle
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                - 13    -
  929.  
  930.  
  931.                     Object.  The ACTION    rou-
  932.                     tine of the     predeclared
  933.                     ADL      Object  STRING  is
  934.                     executed if     the  Direct
  935.                     Object is a    string.
  936.  
  937.           Verb ACTION        The     ACTION     routine  of
  938.                     the    current    Verb is    exe-
  939.                     cuted.   This  is  where
  940.                     general  default actions
  941.                     are      usually   handled.
  942.                     For     example,  the    sen-
  943.                     tence  "Rub     the  floor"
  944.                     might result in the    mes-
  945.                     sage    "Rubbing    that
  946.                     object is not useful."
  947.  
  948. Room ACTION      The ACTION routine of    the current  Actor's
  949.           location  is    executed once the above    loop
  950.           has examined all of  the  Direct  Objects.
  951.           This    routine     is typically a    "transition"
  952.           routine -- that is, it might check whether
  953.           the  current    verb is    "north"    and move the
  954.           current actor    to the appropriate  location
  955.           (it    might    check  other  directions  as
  956.           well!).
  957.  
  958. 4.2.  $exit
  959.  
  960.      It    is possible to change the normal flow  of  execution
  961. by  means of the $exit built-in    routine.  The programmer may
  962. use ($exit 0) to halt execution    of  the     current  phase     and
  963. move  on  to  the next phase.  At any time, ($exit 1) may be
  964. used to    halt the execution of the current phase    and skip  to
  965. the  next  Actor.   Inside the Direct Object loop, ($exit 2)
  966. may be used to skip the    rest of    the Object and Verb  ACTIONs
  967. and  go     on  to     the next Direct Object    in the list.  At any
  968. time after the parsing phase, ($exit 3)    will return the    flow
  969. of  control  to     the Parsing phase without clearing the    sen-
  970. tence.    This allows for    incremental entry of sentences;     for
  971. example    "The big door.    Unlock.     With the key".
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.         c 1987 Ross    Cunniff    and Tim    Brengle
  989.  
  990.  
  991.  
  992.  
  993.  
  994.                - 14    -
  995.  
  996.  
  997.      The following is a    diagram    of the flow of execution:
  998.  
  999.  
  1000.                        START [0]
  1001.                          |
  1002.                          v
  1003.       +--------------------------------->o
  1004.       |                     |
  1005.       |                     v
  1006.       |                  Daemons [1]
  1007.       |                     |
  1008.       |                     v
  1009.       |                 Get Actor <----------------------+
  1010.       |                     |                  |
  1011.       |                     v                  |
  1012.       |      +------------------> Clear Sentence              |
  1013.       |      |                 |                  |
  1014.       |      |                 v                  |
  1015.       |      |      ($exit 3)====> Get Input? --n---> Delete Actor  |
  1016.       |      |                 | y          |      |
  1017.       |      |                 v              |      |
  1018.       |      o<---------------------- Parse?          |      |
  1019.       |      ^                 |              |      |
  1020.       |      |                 v              |      |
  1021.       |      o<-------------fail----- DWIMI          |      |
  1022.       |      ^                 |              |      |
  1023.       |      |                 v              |      |
  1024.       |      +--------------fail----- DWIMD          |      |
  1025.       |                     |              |      |
  1026.       |                     v              |      |
  1027.       |                 Get Dobj <-------+      |      |
  1028.       |                     |          |      |      |
  1029.       |                     v          |      |      |
  1030.       |                   Actor ACTION [2]      |      |      |
  1031.       |                Verb PREACT [3]      |      |      |
  1032.       |                Iobj ACTION [4]      |      |      |
  1033.       |                Dobj ACTION [5]      |      |      |
  1034.       |                Verb ACTION [6]      |      |      |
  1035.       |                     |          |      |      |
  1036.       |                     v          |      |      |
  1037.       |          ($exit 2)===>    More Dobjs? -y----+      |      |
  1038.       |                     | n          |      |
  1039.       |                     v              |      |
  1040.       |                Room ACTION [7]          |      |
  1041.       |                     |              |      |
  1042.       |                     v              |      |
  1043.       |          ($exit 1)=========>o<-------------------+      |
  1044.       |                     |                  |
  1045.       |                     v                  |
  1046.       +--------------------------n-    More Actors? -y-------------------+
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.         c 1987 Ross    Cunniff    and Tim    Brengle
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.                - 15    -
  1061.  
  1062.  
  1063. 5.  ADL    Programs
  1064.  
  1065.      This chapter describes the    format of ADL programs.      An
  1066. ADL program consists of    a list of one or more of the follow-
  1067. ing statements.     Comments in ADL programs are delimited    by {
  1068. and  }.      Since    case is    significant in ADL, tokens which are
  1069. identical except for differing case are    different (for exam-
  1070. ple, "noun" is not the same as "NOUN").
  1071.  
  1072.      Note: for a full BNF specification    of ADL programs, see
  1073. Chapter    8.
  1074.  
  1075.  
  1076.  
  1077. INCLUDE    "filename";
  1078.     Input to the ADL  compiler  is    read  from  filename
  1079.     until  the  end    of file    and compilation    then resumes
  1080.     from the current file.    A file included    in  compila-
  1081.     tion  by  means     of an INCLUDE statement may INCLUDE
  1082.     other files.
  1083.  
  1084.     Example:
  1085.              INCLUDE "standard.adl";
  1086.  
  1087.  
  1088.  
  1089. MESSAGE    "message";
  1090.     The string message is printed on the console at    com-
  1091.     pile time.  This is used to remind the programmer of
  1092.     things which should  be     initialized  or  to  simply
  1093.     reassure  the programmer that the compiler is indeed
  1094.     reading    the file.
  1095.  
  1096.     Example:
  1097.              MESSAGE "Whew!  We're halfway through the file!\n";
  1098.  
  1099.  
  1100.  
  1101. VAR name, name,    ... ;
  1102.     This declares each name    to be a    new global variable.
  1103.     The  contents of global    variables are initialized to
  1104.     zero.  Each  name  must     not  have  been  previously
  1105.     declared.   Each  name    may  be     followed  by a    size
  1106.     specifier, in which case that  number  of  words  is
  1107.     allocated.  As ADL routines have no specific facili-
  1108.     ties for handling arrays, it is     the  responsibility
  1109.     of  the     ADL programmer    to add the desired offset to
  1110.     the base of the    array in order to access an  element
  1111.     of the array For example, ($setg ($plus    Array 10) 5)
  1112.     is similar to Array[ 10    ] = 5 in C.
  1113.  
  1114.     Example:
  1115.              VAR
  1116.                  Score,
  1117.  
  1118.  
  1119.  
  1120.         c 1987 Ross    Cunniff    and Tim    Brengle
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.                - 16    -
  1127.  
  1128.  
  1129.                  Dark,
  1130.                  ObjList[ 10 ],
  1131.                  MyLoc;
  1132.  
  1133.  
  1134.  
  1135. LOCAL name, name, ... ;
  1136.     This statement is only legal inside routine  defini-
  1137.     tions.     It  declares each name    as a new Local Vari-
  1138.     able. Each name    may or may  not     already  have    been
  1139.     declared.   If    a  name     is  the same as the name of
  1140.     something declared outside the routine,     that  thing
  1141.     cannot    be  directly referenced    by the routine.     The
  1142.     name of    a local    variable is only visible to the    rou-
  1143.     tine in    which it is defined.  Local variables may be
  1144.     arrays just as global variables    may.   Note  that  a
  1145.     routine     may  have  a  maximum    of 32 words of local
  1146.     variables.  Arrays of local variables  use  up    that
  1147.     space  rather  quickly,     so they should    be used    with
  1148.     care.  See the next chapter  for  an  example  using
  1149.     local variables.
  1150.  
  1151. VERB name, name, ... ;
  1152.     This statement declares    each name to be    a new  Verb.
  1153.     The PREACT and ACTION routines of Verbs    are initial-
  1154.     ized to    zero.  Each name must not have    been  previ-
  1155.     ously declared.
  1156.  
  1157.     Example:
  1158.              VERB    take, drop, open, close;
  1159.  
  1160.  
  1161.  
  1162. ADJEC name, name, ... ;
  1163.     This statement declares    each name to be    a new Adjec-
  1164.     tive.    Again,    each  name must    not have been previ-
  1165.     ously declared.
  1166.  
  1167.     Example:
  1168.              ADJEC   red, green, blue;
  1169.  
  1170.  
  1171.  
  1172. NOUN ndecl, ndecl, ... ;
  1173.     This statement declares    Objects.  Ndecl    may take the
  1174.     form  obj  or  obj  (  container  ).  The first    form
  1175.     declares a new Object located in  the  object  .ALL.
  1176.     The  second  form  declares  a new Object located in
  1177.     container.  Each obj may be one     of:  an  undeclared
  1178.     identifier,  a    modifier  followed  by an undeclared
  1179.     identifier, or a modifier followed by  a  previously
  1180.     declared  noun.      If obj is just an undeclared iden-
  1181.     tifier,    the identifer is declared to be    a noun and a
  1182.     new  Object  is    created    with that noun ID and with a
  1183.  
  1184.  
  1185.  
  1186.         c 1987 Ross    Cunniff    and Tim    Brengle
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.                - 17    -
  1193.  
  1194.  
  1195.     modifier of 0.    If obj is a modifier followed by  an
  1196.     undeclared identifier, the identifier is declared to
  1197.     be a noun and a    new Object is created with that    noun
  1198.     ID  and     with the modifier set to the one specified.
  1199.     If obj    is  a  modifier     followed  by  a  previously
  1200.     declared  noun,     a  new     Object     is created with the
  1201.     specified noun ID and the specified modifier.    Note
  1202.     that  the declaration "NOUN foo, blue foo;" is ille-
  1203.     gal since it would be too easy to create  situations
  1204.     where  the  player  is    unable    to  disambiguate the
  1205.     Objects.
  1206.  
  1207.     Example:
  1208.              NOUN    room1;
  1209.              NOUN    table( room1 ), chair( room1 ), red ball( room1 );
  1210.  
  1211.  
  1212.  
  1213. ROUTINE    name, name, ...    ;
  1214.     This statement declares    each name to be    a  new    rou-
  1215.     tine.    Note  that this    does not associate a routine
  1216.     with the Routine ID -- it just declares    the routine.
  1217.     This  is  useful  for  daisy-chaining routines (i.e.
  1218.     routine    A calls    routine    B, which  calls     routine  A)
  1219.     since everything must be declared before it is used.
  1220.     Each name must not have    been previously    declared.
  1221.  
  1222.     Example:
  1223.              ROUTINE Looker, Prompter, Quitter;
  1224.  
  1225.  
  1226.  
  1227. ARTICLE    name, name, ...    ;
  1228.     This statement declares    each name to be    a new  Arti-
  1229.     cle.   Each  name  must     not  have  been  previously
  1230.     declared.
  1231.  
  1232.     Example:
  1233.              ARTICLE the, a, an;
  1234.  
  1235.  
  1236.  
  1237. PREP name, name, ... ;
  1238.     This statement declares    each name to be    a new Prepo-
  1239.     sition.      Each    name  must  not    have been previously
  1240.     declared.
  1241.  
  1242.     Example:
  1243.              PREP    in, into, on, above ;
  1244.  
  1245.  
  1246.  
  1247. obj (const) = expr ;
  1248.     This statement assigns property    const of obj  to  be
  1249.  
  1250.  
  1251.  
  1252.         c 1987 Ross    Cunniff    and Tim    Brengle
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.                - 18    -
  1259.  
  1260.  
  1261.     expr.    Const must be a    number or the name of a    con-
  1262.     stant (see below).  Expr may be    a string, a  number,
  1263.     a routine, another noun, or just about anything    else
  1264.     which yields a sixteen bit ID.    Obj must  be  previ-
  1265.     ously  declared.   A warning may be produced if    this
  1266.     particular property is reassigned later    in the    pro-
  1267.     gram.
  1268.  
  1269.     Example:
  1270.              room1( LDESC ) =
  1271.                  ($say "You    are in a huge room.\n")
  1272.              ;
  1273.              chair( WEIGH ) = 450 ;
  1274.              table( MESSAGE ) =    "This space for    rent\n"    ;
  1275.  
  1276.  
  1277.  
  1278. verb (const) = routine ;
  1279.     This statement assigns property    const of verb to  be
  1280.     routine.  Const    must be    either PREACT or ACTION, and
  1281.     verb must have been previously declared.  A  warning
  1282.     may be produced    if this    particular property is reas-
  1283.     signed later in    the program.
  1284.  
  1285.     Example:
  1286.              take( ACTION ) = ($say "You can't take that object.\n");
  1287.              drop( PREACT ) = (CheckAvail);
  1288.  
  1289.  
  1290.  
  1291. name = expr;
  1292.     This statement declares    that name is  equivalent  to
  1293.     expr.    Name  must not have been previously declared
  1294.     and expr may be    an object, a string,  a     routine,  a
  1295.     number,     or  just  about anything else that yields a
  1296.     sixteen-bit value.
  1297.  
  1298.     Example:
  1299.              MagicWord = "AbraCadabra";         { string ID }
  1300.              VISIT = 3;                     { constant    }
  1301.              Silly = ($say "That's silly!\n");         { routine ID }
  1302.              toolbox = tool box;             { object ID }
  1303.  
  1304.  
  1305.  
  1306. (global) = expr;
  1307.     This statement initializes global variable global to
  1308.     have  the  value expr.    Global must have been previ-
  1309.     ously declared and expr    is the same as expr above.
  1310.  
  1311.     Example:
  1312.              ( MyLoc ) = -1;
  1313.              ( Score ) = 10;
  1314.  
  1315.  
  1316.  
  1317.  
  1318.         c 1987 Ross    Cunniff    and Tim    Brengle
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.                - 19    -
  1325.  
  1326.  
  1327. (global    + const) = expr;
  1328.     This statement initializes the const'th    slot in     the
  1329.     global array global to have the    value expr.
  1330.  
  1331.     Example:
  1332.              VAR foo[ 10 ];
  1333.              ( foo ) = 3;         { Sets foo[0] to 3    }
  1334.              ( foo + 5 ) = 6;         { Sets foo[5] to 6    }
  1335.  
  1336.  
  1337.  
  1338. prep1 obj prep2    = prep3;
  1339.     This  statement     declares  that     if  the  three-word
  1340.     sequence  prep1    obj prep2 is encountered during    run-
  1341.     time parsing in    the proper position for     a  preposi-
  1342.     tion,  it  is to be replaced by    prep3.    Obj may    be a
  1343.     modifier-noun pair and prep1, prep2, and prep3    must
  1344.     have been previously declared.
  1345.  
  1346.     Example:
  1347.              PREP
  1348.                  in, of, before;
  1349.              NOUN
  1350.                  front;
  1351.  
  1352.              in    front of = before;
  1353.  
  1354.  
  1355.  
  1356. verb1 prep = verb2;
  1357.     This  statement     declares  that     if   the   two-word
  1358.     sequence  verb1     prep is encountered during run-time
  1359.     parsing    in the proper position for a verb, it is  to
  1360.     be  replaced  by verb2.     Verb1,    verb2, and prep    must
  1361.     have been previously declared.
  1362.  
  1363.     Example:
  1364.              VERB
  1365.                  put, take,    turn, wear, remove, light, douse;
  1366.              PREP
  1367.                  on, off;
  1368.  
  1369.              put on = wear;
  1370.              take off =    remove;
  1371.              turn on = light;
  1372.              turn off =    douse;
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.         c 1987 Ross    Cunniff    and Tim    Brengle
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.                - 20    -
  1391.  
  1392.  
  1393. 6.  Routines
  1394.  
  1395.      This chapter describes the    syntax of ADL routines.      An
  1396. ADL  routine  consists of an optional LOCAL declaration    fol-
  1397. lowed by a sequence of one or more expressions.     An  expres-
  1398. sion is    one of the following:
  1399.  
  1400. Routine    call  A    routine    call in    ADL  takes  the     form  (rout
  1401.           arglist).      Rout    is  either  the     name  of  a
  1402.           built-in routine,    the name of a user  routine,
  1403.           or  an expression    which evaluates    to a Routine
  1404.           ID.  Arglist is a    list of    zero  or  more    args
  1405.           each of which is one of:
  1406.  
  1407.           An expression
  1408.  
  1409.           A    simple expression
  1410.                 A simple expression    is one of  a
  1411.                 string,  a    number,     or  a    name
  1412.                 which was declared as in Chapter
  1413.                 5.
  1414.  
  1415.           @global        This is interpreted    to mean    "the
  1416.                 contents (or value)    of global".
  1417.  
  1418.           %number        This is interpreted    to mean    "the
  1419.                 numberth  argument to this func-
  1420.                 tion".   Note  that     %0  is     the
  1421.                 number  of    arguments  passed to
  1422.                 this function.
  1423.  
  1424.           [    modif noun ]This construct must    be  used  if
  1425.                 the     programmer wants to use the
  1426.                 value of an    Object which  has  a
  1427.                 modifier.
  1428.  
  1429.           The value    of the expression is the  result  of
  1430.           executing    rout with arguments arglist.
  1431.  
  1432. Conditional   A    conditional expression takes the form
  1433.            ( IF    arg1 THEN expression ...
  1434.              ELSEIF arg2 THEN expression ...
  1435.                ...
  1436.              ELSE expression ...  )
  1437.  
  1438.           This  statement  evaluates  arg1    and  if     the
  1439.           result  is  non-zero the expressions following
  1440.           THEN are    executed.   If    the  result  of     the
  1441.           evaluation of arg    is zero    then the expressions
  1442.           following    THEN are skipped until one of  ELSE,
  1443.           ELSEIF  or  the  end  of    the  conditional are
  1444.           found.  If ELSEIF    was found the  corresponding
  1445.           arg is evaluated and execution proceeds as for
  1446.           IF.  If none of  the  ELSEIFs  evaluate  to  a
  1447.  
  1448.  
  1449.  
  1450.         c 1987 Ross    Cunniff    and Tim    Brengle
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.                - 21    -
  1457.  
  1458.  
  1459.           non-zero    value  then the    ELSE expressions are
  1460.           executed.      The  ELSEIFs    and  the  ELSE     are
  1461.           optional.      The conditional expression returns
  1462.           the value    of the last expression    executed  or
  1463.           zero of no expressions were executed.
  1464.  
  1465. Loop          A    loop takes the form ( WHILE arg     DO  expres-
  1466.           sion  ...     ).   If arg evaluates to a non-zero
  1467.           value  then  the    expressions  are  evaluated.
  1468.           This  process  repeats  until arg    evaluates to
  1469.           zero.  This statement always returns zero.
  1470.  
  1471. Example          On the following page is a sample    ADL  routine
  1472.           which  demonstrates  each     of  the  above    con-
  1473.           structs and  is  almost  useful  as  well     See
  1474.           Chapter  7 for the definitions of    the built-in
  1475.           routines called.
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.         c 1987 Ross    Cunniff    and Tim    Brengle
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.                - 22    -
  1523.  
  1524.  
  1525.            { A sample looking daemon }
  1526.            Look    =
  1527.            LOCAL obj;
  1528.                ($incturn)       { Increment the turn    counter    }
  1529.                (IF ($prop ($loc .ME) VISIT)    THEN
  1530.                { I've been here before - print a short description }
  1531.                    ( ($sdesc ($loc .ME)) )
  1532.                 ELSEIF ($ne    ($cont ($loc .ME)) .ME)    THEN
  1533.                { There are other objects here }
  1534.                    ( ($ldesc ($loc .ME)) )
  1535.                    ($say "You can see:\n")
  1536.                    ($setg obj ($cont ($loc .ME)))
  1537.                    (WHILE @obj DO
  1538.                        { Describe each object in the room }
  1539.                        ( ($sdesc @obj) )
  1540.                        ($setg obj ($link @obj))
  1541.                    )
  1542.                 ELSE
  1543.                 { I've never been here }
  1544.                    ( ($ldesc ($loc .ME)) )
  1545.                    ($say "There    is nothing else    in the room.\n")
  1546.                )
  1547.                ($setp ($loc    .ME) VISIT TRUE)
  1548.            ;
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.         c 1987 Ross    Cunniff    and Tim    Brengle
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.                - 23    -
  1589.  
  1590.  
  1591. 7.  ADL    Built-in Routines
  1592.  
  1593.      The following is the complete list    of ADL built-in    rou-
  1594. tines.     They are organized into groups    of related routines.
  1595. A description of each routine is provided with at least     one
  1596. example     to  clarify  its usage.  The following    groupings of
  1597. built-in routines are detailed in this chapter:
  1598.  
  1599.  
  1600.      7.1  Object Routines
  1601.  
  1602.      7.2  Verb Routines
  1603.  
  1604.      7.3  Arithmetic Routines
  1605.  
  1606.      7.4  Boolean Routines
  1607.  
  1608.      7.5  Global Value Routines
  1609.  
  1610.      7.6  Transition Routines
  1611.  
  1612.      7.7  String Manipulation Routines
  1613.  
  1614.      7.8  Name Routines
  1615.  
  1616.      7.9  Conversion Routines
  1617.  
  1618.      7.10 Internal Structure Manipulation Routines
  1619.  
  1620.      7.11 Special Routines
  1621.  
  1622.      7.12 Miscellaneous    Routines
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.         c 1987 Ross    Cunniff    and Tim    Brengle
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                - 24    -
  1655.  
  1656.  
  1657. 7.1.  Object Routines
  1658.  
  1659.      These routines operate primarily on Objects.  They    move
  1660. Objects     around, find Object properties, and set Object    pro-
  1661. perties.
  1662.  
  1663. $loc    ( $loc obj ) ->    The location of    obj.
  1664.  
  1665.     Example:
  1666.              (IF ($eq ($loc .ME) volcano) THEN
  1667.                  ($say "You    are fried to a crisp.\n")
  1668.              )
  1669.  
  1670.  
  1671.  
  1672. $cont    ( $cont    obj ) -> The first object which    is contained
  1673.     in obj.
  1674.  
  1675.     Example:
  1676.              (IF ($eq ($cont .ME) 0) THEN
  1677.                  ($say "You    are empty-handed.\n")
  1678.              )
  1679.  
  1680.  
  1681.  
  1682. $link    ( $link    obj ) -> The next object  contained  in     the
  1683.     same location as obj.
  1684.  
  1685.     Example:
  1686.              ($setg obj    ($cont .ME))
  1687.              (WHILE @obj DO
  1688.                  ($say ($name @obj)    "\n")
  1689.                  ($setg obj    ($link @obj))
  1690.              )
  1691.  
  1692.  
  1693.  
  1694. $ldesc    ( $ldesc obj ) -> The long description of obj.    This
  1695.     is  equivalent to ($prop obj LDESC). Since this    is a
  1696.     Routine    ID, it is typically used as the    callee in  a
  1697.     routine    call.
  1698.  
  1699.     Example:
  1700.              ($setg obj    ($loc .ME))
  1701.              ( ($ldesc @obj) )    { Call LDESC of    ($loc .ME) }
  1702.  
  1703.  
  1704.  
  1705. $sdesc    ( $sdesc obj ) ->  The    short  description  of    obj.
  1706.     This is    equivalent to ($prop obj SDESC).  Since    this
  1707.     is a Routine ID, it is typically used as the  callee
  1708.     in a routine call.
  1709.  
  1710.     Example:
  1711.  
  1712.  
  1713.  
  1714.         c 1987 Ross    Cunniff    and Tim    Brengle
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                - 25    -
  1721.  
  1722.  
  1723.              ($setg obj    ($loc .ME))
  1724.              ( ($sdesc @obj) )    { Call SDESC of    ($loc .ME) }
  1725.  
  1726.  
  1727.  
  1728. $action    ( $action obj )    -> The ACTION routine of obj.    This
  1729.     is  equivalent to ($prop obj ACTION).  Since this is
  1730.     a Routine ID, it is typically used as the callee  in
  1731.     a routine call.
  1732.  
  1733.     Example:
  1734.              ( ($action    .ME) )    { Call ACTION of .ME }
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.         c 1987 Ross    Cunniff    and Tim    Brengle
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                - 26    -
  1787.  
  1788.  
  1789. $modif    ( $modif obj ) -> The modifier of obj.    This is    zero
  1790.     if there is no modifier, negative if the modifier is
  1791.     a Verb,    and positive if    the modifier  is  an  Adjec-
  1792.     tive.
  1793.  
  1794.     Example:
  1795.              (IF ($eq ($modif [    blue ball ] ) blue) THEN
  1796.                  ($say "$modif works!\n")
  1797.              )
  1798.              (IF ($eq ($modif [    north wall ] ) ($minus 0 north)) THEN
  1799.                  ($say "$modif still works!\n")
  1800.              )
  1801.              (IF ($eq ($modif room1) 0)    THEN
  1802.                  ($say "$modif comes through one more time!\n")
  1803.              )
  1804.  
  1805.  
  1806.  
  1807. $prop    ( $prop    obj num    ) -> The numth property    of obj.
  1808.  
  1809.     Example:
  1810.              ($setg obj    ($loc .ME))
  1811.              (IF ($prop    @obj VISIT) THEN
  1812.                  ($say "I've been here before!\n")
  1813.              )
  1814.  
  1815.  
  1816.  
  1817. $setp    ( $setp    obj num    val ) -> No return value.  Sets     the
  1818.     numth property of obj to val.
  1819.  
  1820.     Example:
  1821.              ($setg obj    ($loc .ME))
  1822.              ($setp @obj VISIT TRUE)
  1823.  
  1824.  
  1825.  
  1826. $move    ( $move    obj loc    ) -> No    return value.  Moves obj  to
  1827.     loc.   WARNING:      Do not attempt to violate the    tree
  1828.     structure of objects (e.g. ($move .ALL    foobar))  or
  1829.     horrible and unpredictable things will happen.
  1830.  
  1831.     Example:
  1832.              (IF ($eq @Verb north) THEN
  1833.                  ($move .ME    room2)
  1834.              )
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.         c 1987 Ross    Cunniff    and Tim    Brengle
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.                - 27    -
  1853.  
  1854.  
  1855. 7.2.  Verb Routines
  1856.  
  1857.      These two routines    operate    on Verbs.  They    are provided
  1858. for scenarios in which the properties of Verbs may change.
  1859.  
  1860. $vset    ( $vset    verb prop val )    -> No return value. The    pro-
  1861.     perty  prop  of     verb  is  set to val.    Prop must be
  1862.     either PREACT or ACTION.
  1863.  
  1864.     Example:
  1865.              ($vset @Verb PREACT Silly)
  1866.  
  1867.  
  1868.  
  1869. $vprop    ( $vprop verb prop ) ->    The value of  property    prop
  1870.     of verb.  Prop must be either PREACT or    ACTION.
  1871.  
  1872.     Example:
  1873.              { Call Verb's PREACT }
  1874.              ( ($vprop @Verb PREACT) )
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.         c 1987 Ross    Cunniff    and Tim    Brengle
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.                - 28    -
  1919.  
  1920.  
  1921. 7.3.  Arithmetic Routines
  1922.  
  1923.      These  routines  operate    on   arbitrary     sixteen-bit
  1924. numbers,  and  return  sixteen-bit  values.   Note  that the
  1925. numbers    may actually be    Object IDs, global variable IDs,  or
  1926. any of the sixteen bit IDs used    by ADL.
  1927.  
  1928. $plus    ( $plus    num1 num2 ) -> Returns num1 + num2.
  1929.  
  1930.     Example:
  1931.              ($setg Score ($plus @Score    50))
  1932.  
  1933.  
  1934.  
  1935. $minus    ( $minus num1 num2 ) ->    Returns    num1 - num2.
  1936.  
  1937.     Example:
  1938.              ($setg LivesLeft ($minus @LivesLeft 1))
  1939.  
  1940.  
  1941.  
  1942. $times    ( $times num1 num2 ) ->    Returns    num1 * num2.
  1943.  
  1944.     Example:
  1945.              ($setg TimeLeft ($times @NumBattery 10))
  1946.  
  1947.  
  1948.  
  1949. $div    ( $div num1 num2 ) -> Returns num1 / num2.
  1950.  
  1951.     Example:
  1952.              ($setg Rating ($div @Score    100))
  1953.  
  1954.  
  1955.  
  1956. $mod    ( $mod num1 num2 ) -> Returns  the  remainder  which
  1957.     results     when  num1  is    divided    by num2    according to
  1958.     normal integer division.
  1959.  
  1960.     Example:
  1961.              { Make sure XPos is from 0    to 9 }
  1962.              ($setg XPos ($mod @Xpos 10))
  1963.  
  1964.  
  1965.  
  1966. $rand    ( $rand    num ) -> Returns a random number from  1  to
  1967.     num inclusive.
  1968.  
  1969.     Example:
  1970.              { Move the    player to a random room    from room1 to room10 }
  1971.              ($setg Num    ($rand 10))
  1972.              ($move .ME    ($plus room1 ($minus @Num 1)))
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.         c 1987 Ross    Cunniff    and Tim    Brengle
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.                - 29    -
  1985.  
  1986.  
  1987. 7.4.  Boolean Routines
  1988.  
  1989.      These routines are    typically used in  conditionals     and
  1990. loops.     However,  traditional    bit-masking may    be done    with
  1991. $and and $or.
  1992.  
  1993.  
  1994. $and    ( $and a b c ... ) -> Returns the bitwise AND of the
  1995.     vector    a b c ....  Note that since this is the    bit-
  1996.     wise AND, care must be    taken  in  conditions  since
  1997.     ANDing    two  non-zero  values  does  not necessarily
  1998.     return a non-zero value.
  1999.  
  2000.     Example:
  2001.              ($and 2 4)    is 0 (0b0001 AND 0b0010    = 0b0000)
  2002.              ($and 3 7)    is 3 (0b0011 AND 0b0111    = 0b0011)
  2003.              ($and 1 1)    is 1 (0b0001 AND 0b0001    = 0b0001)
  2004.  
  2005.  
  2006.  
  2007. $or    ( $or a    b c ...    ) -> Returns the bitwise OR  of     the
  2008.     vector a b c ....
  2009.  
  2010.     Example:
  2011.              ($or 0 0) is 0  (0b0000 OR    0b0000 = 0b0000)
  2012.              ($or 1 2) is 3  (0b0001 OR    0b0010 = 0b0011)
  2013.              ($or 1 1) is 1  (0b0001 OR    0b0001 = 0b0001)
  2014.  
  2015.  
  2016.  
  2017. $not    ( $not num ) ->    Returns    zero if    num is non-zero     and
  2018.     one  if     num is    zero.  Note that this is BOOLEAN NOT
  2019.     and not    BITWISE    NOT.  BITWISE NOT could    be coded  as
  2020.     ($minus     ($minus  0  %1)  1)  for a two's complement
  2021.     machine.
  2022.  
  2023.     Example:
  2024.              ($not 0) is 1
  2025.              ($not 1) is 0
  2026.              ($not 5) is 0
  2027.  
  2028.  
  2029.  
  2030. $yorn    ( $yorn    ) -> Waits for the player to type a line  of
  2031.     input,    returns     one  if  this    line begins with the
  2032.     letter 'Y' or 'y', and returns zero otherwise.    Note
  2033.     that no    prompt is automatically    made for this input.
  2034.  
  2035.     Example:
  2036.              ($say "Are    you sure you want to quit? ")
  2037.              (IF ($yorn) THEN
  2038.                  ($say "OK.     Goodbye!\n")
  2039.                  ($spec 3)
  2040.               ELSE
  2041.  
  2042.  
  2043.  
  2044.         c 1987 Ross    Cunniff    and Tim    Brengle
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                - 30    -
  2051.  
  2052.  
  2053.                  ($say "Whew! That was a close one!\n")
  2054.              )
  2055.  
  2056.  
  2057.  
  2058. $pct    ( $pct num ) ->    Returns    one num    percent    of the    time
  2059.     and  zero  the rest of the time.  This is equivalent
  2060.     to ($ge    num ($rand 100)).
  2061.  
  2062.     Example:
  2063.              (IF ($pct 30) THEN
  2064.                  ($say "The    troll swings at    you, and hits!\n")
  2065.               ELSE
  2066.                  ($say "The    troll's    axe misses you by a hair!\n")
  2067.              )
  2068.  
  2069.  
  2070.  
  2071. $eq    ( $eq num1 num2    ) -> Returns one if num1 is equal to
  2072.     num2 and zero otherwise.
  2073.  
  2074.     Example:
  2075.              ($setg loc    ($loc .ME))
  2076.              (IF ($eq @loc room1) THEN
  2077.                  ($say "You    are in room 1.\n")
  2078.              )
  2079.  
  2080.  
  2081.  
  2082. $ne    ( $ne num1 num2    ) -> Returns  one  if  num1  is     not
  2083.     equal to num2 and zero otherwise.
  2084.  
  2085.     Example:
  2086.              ($setg loc    ($loc .ME))
  2087.              (IF ($ne @LastLoc @loc) THEN
  2088.                  ($say "You've moved since I last checked!\n")
  2089.              )
  2090.  
  2091.  
  2092.  
  2093. $lt    ( $lt num1 num2    ) -> Returns one  if  num1  is    less
  2094.     than num2 and zero otherwise.
  2095.  
  2096.     Example:
  2097.              (IF ($lt @Score 100) THEN
  2098.                  ($say "You    are a novice adventurer\n")
  2099.              )
  2100.  
  2101.  
  2102.  
  2103. $gt    ( $gt num1 num2    ) -> Returns one if num1 is  greater
  2104.     than num2 and zero otherwise.
  2105.  
  2106.     Example:
  2107.  
  2108.  
  2109.  
  2110.         c 1987 Ross    Cunniff    and Tim    Brengle
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                - 31    -
  2117.  
  2118.  
  2119.              (IF ($gt @Score 1000) THEN
  2120.                  ($say "You    are a super master grand ")
  2121.                  ($say "champion mongo adventurer!!!\n")
  2122.              )
  2123.  
  2124.  
  2125.  
  2126. $le    ( $le num1 num2    ) -> Returns one  if  num1  is    less
  2127.     than or    equal to num2 and zero otherwise.
  2128.  
  2129.     Example:
  2130.              (IF ($le @Score 1000) THEN
  2131.                  ($say "You    are a pretty good adventurer.\n")
  2132.              )
  2133.  
  2134.  
  2135.  
  2136. $ge    ( $ge num1 num2    ) -> Returns one if num1 is  greater
  2137.     than or    equal to num2 and zero otherwise.
  2138.  
  2139.     Example:
  2140.              (IF ($ge @Weight 200) THEN
  2141.                  ($say "The    ice breaks under your weight!\n")
  2142.              )
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.         c 1987 Ross    Cunniff    and Tim    Brengle
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                - 32    -
  2183.  
  2184.  
  2185. 7.5.  Global Value Routines
  2186.  
  2187.  
  2188. $setg    ( $setg    which val ) -> Returns val.  Sets  the    con-
  2189.     tents of (or the value of) variable which to be    val.
  2190.  
  2191. $global    ( $global which    ) -> Returns the contents of (or the
  2192.     value  of)  variable  which.   Equivalent to @which,
  2193.     with the exception that     $global  allows  arithmetic
  2194.     expressions.
  2195.  
  2196.     Example:
  2197.              Given:
  2198.                  VAR var[3];
  2199.                  (var + 0) = 10;
  2200.                  (var + 1) = 20;
  2201.                  (var + 2) = 30;
  2202.  
  2203.              The statement
  2204.                  ($global ($plus var 2))
  2205.              would return 30.
  2206.  
  2207.  
  2208.  
  2209. $verb    ( $verb    ) -> Returns the current  Verb.      Equivalent
  2210.     to @Verb.
  2211.  
  2212.     Example:
  2213.              (IF ($eq ($verb) take) THEN
  2214.                  ($say "You    can't take that!!\n")
  2215.              )
  2216.  
  2217.  
  2218.  
  2219. $dobj    ( $dobj    ) ->  Returns  the  current  direct  object.
  2220.     Equivalent to @Dobj.
  2221.  
  2222.     Example:
  2223.              (IF ($eq ($dobj) ball) THEN
  2224.                  ($say "Dobj = ball\n")
  2225.              )
  2226.  
  2227.  
  2228.  
  2229. $iobj    ( $iobj    ) -> Returns the  current  indirect  object.
  2230.     Equivalent to @Iobj.
  2231.  
  2232.     Example:
  2233.              (IF ($eq ($iobj) basket) THEN
  2234.                  ($say "Iobj = basket\n")
  2235.              )
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.         c 1987 Ross    Cunniff    and Tim    Brengle
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.                - 33    -
  2249.  
  2250.  
  2251. $prep    (  $prep  )  ->     Returns  the  current    Preposition.
  2252.     Equivalent to @Prep.
  2253.  
  2254.     Example:
  2255.              (IF ($eq ($prep) into) THEN
  2256.                  ($say "Prep = into\n")
  2257.              )
  2258.  
  2259.  
  2260.  
  2261. $conj    (  $conj  )  ->     Returns  the  current    conjunction.
  2262.     Equivalent to @Conj.
  2263.  
  2264.     Example:
  2265.              (IF ($eq ($conj) 1) THEN
  2266.                  ($say "The    conjunction was    'but'\n")
  2267.               ELSE
  2268.                  ($say "The    conjunction was    'and' or ','\n")
  2269.              )
  2270.  
  2271.  
  2272.  
  2273. $numd    ( $numd    ) ->  Returns  the  length  of    the  current
  2274.     direct object list.  Equivalent    to @Numd.
  2275.  
  2276.     Example:
  2277.              (IF ($gt ($numd) 1) THEN
  2278.                  ($say "You    may not    use multiple direct objects!\n")
  2279.              )
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.         c 1987 Ross    Cunniff    and Tim    Brengle
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.                - 34    -
  2315.  
  2316.  
  2317. 7.6.  Transition Routines
  2318.  
  2319.      ADL has an    internal structure known as  the  Transition
  2320. Vector.     This structure    is a list of ten verb IDs and is set
  2321. and used by the    following routines.  These routines are    typ-
  2322. ically    used in    the ACTION routines of rooms in    scenarios in
  2323. order to move the player around.
  2324.  
  2325. $setv    ( $setv    verb1 verb2 verb3 ... verb10 ) -> No  return
  2326.     value.     Initializes  the  Transition  Vector to the
  2327.     list of    verbs verb1 verb2 verb3    ... verb10.
  2328.  
  2329.     Example:
  2330.              ($setv north south    east west ne se    nw sw up down)
  2331.  
  2332.  
  2333.  
  2334. $hit    ( $hit obj loc1    loc2 loc3 ... loc10 ) ->  No  return
  2335.     value.    Scans the Transition Vector for    a match    with
  2336.     the current Verb.  If found, obj  is  moved  to     the
  2337.     corresponding  loc.   Nothing happens if no match is
  2338.     found.    An attempt to move an object to     location  0
  2339.     (.ALL) is ignored.
  2340.  
  2341.     Example:
  2342.              room1(ACTION) =
  2343.                  ($hit .ME room2 room3 room4 0 0 0 0 0 0 0)
  2344.              ;
  2345.  
  2346.  
  2347.  
  2348. $miss    ( $miss    rout1 rout2 rout3 ... rout10 ) -> No  return
  2349.     value.    Scans the Transition Vector for    a match    with
  2350.     the current Verb.  If found, the corresponding    rout
  2351.     is  called.   Nothing  happens if no match is found.
  2352.     An attempt to call routine 0 does nothing.
  2353.  
  2354.     Example:
  2355.              cg    = ($say    "You can't go that way.\n")
  2356.  
  2357.              room2(ACTION) =
  2358.                  ($miss 0 0    0 cg cg    cg cg cg cg cg)
  2359.              ;
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.         c 1987 Ross    Cunniff    and Tim    Brengle
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                - 35    -
  2381.  
  2382.  
  2383. 7.7.  String Manipulation Routines
  2384.  
  2385.      There are basically three types of    strings    which an ADL
  2386. program     uses.    The first type of string is the    compile-time
  2387. string (a string which was present in the ADL source file of
  2388. the  scenario).      All  compile-time  strings have a positive
  2389. string ID and exist for    the duration of    program    execution.
  2390.  
  2391.      The second    type of    string is  the    "volatile"  run-time
  2392. string.      Examples  of    this  type of string include strings
  2393. typed by the player and    strings    produced by the    builtin    rou-
  2394. tines  $subs,  $cat,  $read,  $name, $vname, $mname, $pname,
  2395. $num, and $chr (see also Sections 7.8  and  7.9).   Volatile
  2396. strings     have  negative     string    IDs and    are "flushed" at the
  2397. beginning of each turn (just before the    Daemon phase).
  2398.  
  2399.      The third type of string is the "non-volatile" run-time
  2400. string.      These     strings  also    have negative string IDs but
  2401. they are never "flushed".  These strings are produced by the
  2402. $savestr routine.  Note    that there is no easy way to distin-
  2403. guish volatile and non-volatile    run-time strings.
  2404.  
  2405.      In    the context of the $subs and $pos routines,  strings
  2406. are  indexed  starting    at  zero (the first character of the
  2407. string).  The following    routines operate  on  all  types  of
  2408. strings:
  2409.  
  2410. $eqst    ( $eqst    str1 str2 ) -> Returns one if str1  has     the
  2411.     same contents as str2 and zero otherwise.  Note    that
  2412.     this is    NOT the    same as    ($eq str1 str2),  since     the
  2413.     $eq only compares the string IDs of the    strings.
  2414.  
  2415.     Example:
  2416.              The program:
  2417.                  ($setg str1 "hello")
  2418.                  ($setg str2 ($cat "he" "llo"))
  2419.                  (IF ($eqst    @str1 @str2) THEN
  2420.                      ($say "String 1 ==    string 2\n")
  2421.                  )
  2422.                  (IF ($ne @str1 @str2) THEN
  2423.                      ($say "String ID 1    != string ID 2\n")
  2424.                  )
  2425.  
  2426.              will produce the output:
  2427.                  String 1 == string    2
  2428.                  String ID 1 != string ID 2
  2429.  
  2430.  
  2431.  
  2432. $subs    ( $subs    str start len )    -> Returns a  volatile    copy
  2433.     of  the    substring of str starting at start and going
  2434.     for len    characters.  If    len is 0, the suffix of     str
  2435.     starting at start is returned.
  2436.  
  2437.  
  2438.  
  2439.  
  2440.         c 1987 Ross    Cunniff    and Tim    Brengle
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.                - 36    -
  2447.  
  2448.  
  2449.     Example:
  2450.              The program:
  2451.                  ($setg str    "Hello world")
  2452.                  ($say ($subs @str 0 5) "\n")
  2453.                  ($say ($subs @str 6 0) "\n")
  2454.  
  2455.              will produce the output:
  2456.                  Hello
  2457.                  world
  2458.  
  2459.  
  2460.  
  2461. $leng    ( $leng    str ) -> Returns the length of str.
  2462.  
  2463.     Example:
  2464.              ($leng "Hello") is    5
  2465.              ($leng "")    is 0
  2466.  
  2467.  
  2468.  
  2469. $cat    ( $cat str1 str2 )  ->    Returns     a  volatile  string
  2470.     which is the result of concatenating str1 and str2.
  2471.  
  2472.     Example:
  2473.              ($cat "hello " "world") returns "hello world"
  2474.  
  2475.  
  2476.  
  2477. $pos    ( $pos str1 str2 ) -> Returns the position  of    str1
  2478.     in str2.  If no    occurrence of str1 is found in str2,
  2479.     -1 is returned.
  2480.  
  2481.     Example:
  2482.              ($pos "hello" "hello world") is 0
  2483.              ($pos "Foobar" "bletch") is -1
  2484.              ($pos "testing" "This is a    test") is -1
  2485.              ($pos "is"    "This is a test") is 2
  2486.  
  2487.  
  2488.  
  2489. $read    ( $read    ) -> Returns a volatile    string which is    read
  2490.     from  the player's keyboard.  Note that    no prompt is
  2491.     automatically generated.
  2492.  
  2493.     Example:
  2494.              ($say "What is your name? ")
  2495.              ($setg MyName ($read))
  2496.              ($say "Hello, " @MyName ",    welcome    to ADL!\n")
  2497.  
  2498.  
  2499.  
  2500. $savestr( $savestr str ) -> Returns a non-volatile  copy  of
  2501.     str.   Note  that  str may be any string -- compile-
  2502.     time, volatile,    or non-volatile.
  2503.  
  2504.  
  2505.  
  2506.         c 1987 Ross    Cunniff    and Tim    Brengle
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.                - 37    -
  2513.  
  2514.  
  2515.     Example:
  2516.              ($setg MyName ($savestr @MyName))
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.         c 1987 Ross    Cunniff    and Tim    Brengle
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.                - 38    -
  2579.  
  2580.  
  2581. 7.8.  Name Routines
  2582.  
  2583.      The following  routines  all  return  volatile  strings
  2584. which contain the requested name.
  2585.  
  2586. $name    ( $name    obj ) -> Returns a volatile string  contain-
  2587.     ing the    (possibly multiple-word) name of obj.
  2588.  
  2589.     Example:
  2590.              ($say "You    see no " ($name    @Dobj) " here!\n")
  2591.  
  2592.  
  2593.  
  2594. $vname    ( $vname verb )    -> Returns a  volatile    string    con-
  2595.     taining    the name of verb.
  2596.  
  2597.     Example:
  2598.              ($say "No multiple    objects    with " ($vname @Verb) "!\n")
  2599.  
  2600.  
  2601.  
  2602. $mname    ( $mname modif ) -> Returns a volatile    string    con-
  2603.     taining:  the  name  of     modifier modif    (if modif is
  2604.     greater    than zero), the     name  of  verb     -modif     (if
  2605.     modif  is  less     than  zero), or the null string (if
  2606.     modif is zero).
  2607.  
  2608.     Example:
  2609.              ($say "The    modifier of blue ball is " ($mname blue) "\n")
  2610.  
  2611.  
  2612.  
  2613. $pname    ( $pname prep )    -> Returns a  volatile    string    con-
  2614.     taining    the name of Preposition    prep.
  2615.  
  2616.     Example:
  2617.              ($say "The    sentence is:\n")
  2618.              ($say   ($vname @Verb) " "
  2619.                  ($name @Dobj) " "
  2620.                  ($pname @Prep) " "
  2621.                  ($name @Iobj)
  2622.              )
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.         c 1987 Ross    Cunniff    and Tim    Brengle
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.                - 39    -
  2645.  
  2646.  
  2647. 7.9.  Conversion Routines
  2648.  
  2649.      The  following  routines  perform    conversions  between
  2650. strings    and numbers.
  2651.  
  2652. $str    ( $str num ) ->    Returns    a volatile string which    con-
  2653.     tains the ASCII    representation of num.
  2654.  
  2655.     Example:
  2656.              ($str 3) is the string "3"
  2657.  
  2658.  
  2659.  
  2660. $num    ( $num str ) ->    Returns    the numeric value of str.
  2661.  
  2662.     Example:
  2663.              ($num "234") is the number    234
  2664.  
  2665.  
  2666.  
  2667. $ord    ( $ord str ) ->    Returns    the ASCII code of the  first
  2668.     character in str.
  2669.  
  2670.     Example:
  2671.              ($ord "ABC") is 65
  2672.  
  2673.  
  2674.  
  2675. $chr    ( $chr num ) ->    Returns    a volatile string which    con-
  2676.     tains  exactly    one  character,     whose ASCII code is
  2677.     num.
  2678.  
  2679.     Example:
  2680.              ($chr 97) is the string "a".
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.         c 1987 Ross    Cunniff    and Tim    Brengle
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                - 40    -
  2711.  
  2712.  
  2713. 7.10.  Internal    Structure Manipulation Routines
  2714.  
  2715.      The following routines are    the means  whereby  the     ADL
  2716. programmer  may     modify    the Internal Structures    described in
  2717. Chapter    3.  See    also Chapter 4 for the use of some of  these
  2718. routines.
  2719.  
  2720. $sdem    ( $sdem    rout ) -> No return value.   Activates    rout
  2721.     as a daemon.
  2722.  
  2723.     Example:
  2724.              ($sdem Looker)
  2725.              ($sdem Follower)
  2726.  
  2727.  
  2728.  
  2729. $ddem    ( $ddem    rout ) ->  No  return  value.    De-activates
  2730.     rout as    a daemon.  No action is    taken if rout is not
  2731.     an active daemon.
  2732.  
  2733.     Example:
  2734.              ($ddem Follower)
  2735.  
  2736.  
  2737.  
  2738. $sfus    ( $sfus    actor rout  count  )  ->  No  return  value.
  2739.     Activates rout as a fuse associated with actor to be
  2740.     executed in count turns.
  2741.  
  2742.     Example:
  2743.              ($sfus .ME    LampDie    300)
  2744.  
  2745.  
  2746.  
  2747. $dfus    ( $dfus    actor  rout  )    ->  No    return    value.     De-
  2748.     activates  rout    as a fuse associated with actor.  No
  2749.     action is taken    if rout    is not an active fuse.
  2750.  
  2751.     Example:
  2752.              (IF @BatteryFound THEN
  2753.                  ($dfus .ME    LampDie)
  2754.              )
  2755.  
  2756.  
  2757.  
  2758. $incturn( $incturn [ nturns ] )    -> No return value.   Incre-
  2759.     ments  the turn    counter    by nturns (or 1    if nturns is
  2760.     not given) and activates any fuses  associated    with
  2761.     the  current  actor  that  have     "burned down".     The
  2762.     "burned    down" fuses are    then de-activated.  The     ADL
  2763.     programmer  to "halt time" by refraining from incre-
  2764.     menting    the turn counter.   Usually,  ($incturn)  is
  2765.     only  called  when the daemons are executing for the
  2766.     primary    actor.    For other actors,  ($incturn  0)  is
  2767.  
  2768.  
  2769.  
  2770.         c 1987 Ross    Cunniff    and Tim    Brengle
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.                - 41    -
  2777.  
  2778.  
  2779.     used  to  see  whether the fuses associated with the
  2780.     current    actor have burned down,    without    incrementing
  2781.     the turn counter.
  2782.  
  2783.     Example:
  2784.              sleep(ACTION) = ($incturn 300) ;
  2785.  
  2786.  
  2787.  
  2788. $turns    ( $turns ) -> Returns the current value    of the    turn
  2789.     counter.
  2790.  
  2791.     Example:
  2792.              (IF ($eq @Verb north) THEN
  2793.                  (IF ($gt ($turns) 230) THEN
  2794.                      ($move .ME    room3)
  2795.                   ELSE
  2796.                      ($move .ME    room5)
  2797.                  )
  2798.              )
  2799.  
  2800.  
  2801.  
  2802. $prompt    ( $prompt rout )  ->  No  return  value.   Sets     the
  2803.     prompter to be rout.
  2804.  
  2805.     Example:
  2806.              ($prompt Prompter)
  2807.  
  2808.  
  2809.  
  2810. $actor    (  $actor  obj    str  flag  )  ->  No  return  value.
  2811.     Activates  obj    as  a new Actor    with the line buffer
  2812.     initialized to str.  If    flag is     non-zero  then     the
  2813.     new Actor will be interactive.    If flag    is zero    then
  2814.     the new    Actor will be non-interactive.     If  str  is
  2815.     zero then the line buffer will be initialized to the
  2816.     empty string.
  2817.  
  2818.     Example:
  2819.              ($actor Myself NULL TRUE)
  2820.              ($setg s "Go east then south.  Push button.  Go north")
  2821.              ($actor robot @s FALSE)
  2822.  
  2823.  
  2824.  
  2825. $delact    ( $delact obj )    -> No  return  value.    Deletes     the
  2826.     Actor  associated  with    obj from the Actor list.  No
  2827.     action is performed if obj is not an active Actor.
  2828.  
  2829.     Example:
  2830.              (IF ($prop    robot BROKEN) THEN
  2831.                  ($delact robot)
  2832.              )
  2833.  
  2834.  
  2835.  
  2836.         c 1987 Ross    Cunniff    and Tim    Brengle
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.                - 42    -
  2843.  
  2844.  
  2845. $define    ( $define str1 str2 ) -> No return  value.   Informs
  2846.     the parser that    upon input from    an Actor, the string
  2847.     str1 is    to be replaced with the     contents  of  str2.
  2848.     This  process  continues  until     an infinite loop is
  2849.     detected or until a word is found for which there is
  2850.     no  corresponding  expansion.    Str1 must contain no
  2851.     spaces.     Str2 may contain several words    separated by
  2852.     spaces.      Note    that in    the case of multiple defini-
  2853.     tions  (such  as  ($define  "a"     "b")  followed      by
  2854.     ($define "a" "c")), the    macro table should be viewed
  2855.     as a stack with    $define    pushing    macro definitions on
  2856.     the stack and $undef popping definitions.
  2857.  
  2858.     Example:
  2859.              (IF ($eq @MyDir 1)    THEN
  2860.                  ($define "left" "north")
  2861.                  ($define "right" "south")
  2862.               ELSE
  2863.                  ($define "left" "south")
  2864.                  ($define "right" "north")
  2865.              )
  2866.  
  2867.  
  2868.  
  2869. $undef    ( $undef str ) -> No  return  value.   This  routine
  2870.     removes     str and its expansion from the    macro table.
  2871.     No action is performed    if  str     is  not  an  active
  2872.     macro.
  2873.  
  2874.     Example:
  2875.              ($undef "left")
  2876.              ($undef "right")
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.         c 1987 Ross    Cunniff    and Tim    Brengle
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.                - 43    -
  2909.  
  2910.  
  2911. 7.11.  Special Routines
  2912.  
  2913. $spec    ( $spec    code arg1 arg2    ...  argN  )  ->  No  return
  2914.     value.     Performs a special, system-dependent opera-
  2915.     tion.  Note that not all  operations  exist  in     all
  2916.     implementations.   Consult your    local ADL documenta-
  2917.     tion for information.
  2918.  
  2919.  
  2920.       +------+---------------------------------------+
  2921.       | code |         function         |
  2922.       +------+---------------------------------------+
  2923.       |  1     |   Toggle the    instruction trace flag     |
  2924.       |  2     |         Restart this game         |
  2925.       |  3     |    Terminate    execution of this game     |
  2926.       |  4     |    Save this game in file arg1     |
  2927.       |  5     |    Restore this game    from file arg1     |
  2928.       |  6     | Execute the system program named arg1 |
  2929.       |  7     |  Preserve unknown words in file arg1     |
  2930.       |  8     |    Write a    script to file arg1     |
  2931.       |  9     |   Print a header line on the    screen     |
  2932.       |  10     |        Set    the right margin     |
  2933.       +------+---------------------------------------+
  2934.  
  2935.     Function 1
  2936.          Toggles the instruction trace  flag.   If    this
  2937.          flag  is  set,  an     instruction trace and stack
  2938.          dump are printed for every    ADL instruction    exe-
  2939.          cuted (a very messy but informative process).
  2940.  
  2941.     Function 2
  2942.          Re-initializes all     ADL  structures  and  vari-
  2943.          ables,  re-executes START,    and generally starts
  2944.          the game over from    the beginning.
  2945.  
  2946.     Function 3
  2947.          Terminates    the game immediately,  no  questions
  2948.          asked.
  2949.  
  2950.     Function 4
  2951.          Saves a "core image" of the ADL structures     and
  2952.          variables sufficient to restore the game to the
  2953.          same position later.
  2954.  
  2955.     Function 5
  2956.          Reads a "core image" which     was  created  by  a
  2957.          previous invocation of Function 4,    thus restor-
  2958.          ing the game to its previous state.
  2959.  
  2960.     Function 6
  2961.          Runs  the    program     arg1  with  arguments    arg2
  2962.          through  argN.   All arguments must be strings,
  2963.          except the    last argument which must be 0.
  2964.  
  2965.  
  2966.  
  2967.  
  2968.         c 1987 Ross    Cunniff    and Tim    Brengle
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.                - 44    -
  2975.  
  2976.  
  2977.     Function 7
  2978.          Starts recording those words from the  player's
  2979.          input  which  are    unrecognized by    the run-time
  2980.          parser.  The words    are  appended  to  the    file
  2981.          named  by    arg1.    This recording is stopped if
  2982.          arg1 is 0.
  2983.  
  2984.     Function 8
  2985.          Starts recording a    "script" of  all  input     and
  2986.          output produced during the    subsequent execution
  2987.          of    the game.  The script is  written  into     the
  2988.          file named    by arg1.  Stops    recording if arg1 is
  2989.          0.
  2990.  
  2991.     Function 9
  2992.          Prints  a    line  of   the     form    "Room    Name
  2993.          Score:  NN       Moves:  NN"    at  the     top  of the
  2994.          screen.  It is assumed that arg1 is the name of
  2995.          the  room,     arg2 is the current score, and    arg3
  2996.          is    the number of turns that have passed.
  2997.  
  2998.     Function 10
  2999.          Sets the right margin to arg1.   This  function
  3000.          is     provided  for    the use    of those games whose
  3001.          messages would  look  better  on  narrower     (or
  3002.          wider) screens than the default of    80 columns.
  3003.  
  3004.     Examples:
  3005.              VERB debug;
  3006.              debug(ACTION) = ($spec 1);
  3007.  
  3008.              VERB restart;
  3009.              restart(ACTION) = ($spec 2);
  3010.  
  3011.              VERB quit;
  3012.              quit(ACTION) = ($spec 3);
  3013.  
  3014.              VERB save;
  3015.              save(ACTION) =
  3016.              LOCAL name;
  3017.                  ($say "Save to what filename? ")
  3018.                  ($setg name ($read))
  3019.                  (IF ($leng    @name) THEN
  3020.                      ($spec 4 @name)
  3021.                  )
  3022.              ;
  3023.  
  3024.              VERB restore;
  3025.              restore(ACTION) =
  3026.              LOCAL name;
  3027.                  ($say "Restore from what filename?    ")
  3028.                  ($setg name ($read))
  3029.                  (IF ($leng    @name) THEN
  3030.                      ($spec 5 @name)
  3031.  
  3032.  
  3033.  
  3034.         c 1987 Ross    Cunniff    and Tim    Brengle
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.                - 45    -
  3041.  
  3042.  
  3043.                  )
  3044.              ;
  3045.  
  3046.              VERB shell;
  3047.              shell(ACTION) =
  3048.                  ($spec 6 "/bin/csh")
  3049.              ;
  3050.  
  3051.              VERB savewords;
  3052.              savewords(ACTION) =
  3053.                  ($spec 7 "unknown.wrds")
  3054.              ;
  3055.  
  3056.              VERB script;
  3057.              script(ACTION) =
  3058.              LOCAL name;
  3059.                  ($say "Script to what filename? ")
  3060.                  ($setg name ($read))
  3061.                  (IF ($leng    @name) THEN
  3062.                      ($spec 8 @name)
  3063.                  )
  3064.              ;
  3065.  
  3066.              Status = ($spec 9 ($name ($loc .ME)) @Score ($turns)) ;
  3067.  
  3068.              START = ($spec 10 60);  { It makes    the text prettier }
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.         c 1987 Ross    Cunniff    and Tim    Brengle
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.                - 46    -
  3107.  
  3108.  
  3109. 7.12.  Miscellaneous Routines
  3110.  
  3111.      These routines are    placed here for     lack  of  a  better
  3112. place to put them.
  3113.  
  3114.  
  3115. $say    ( $say str1 str2 ... ) -> No return  value.   Prints
  3116.     the messages str1 str2 ... on the screen.  Note    that
  3117.     ADL automatically "word-wraps" strings so that    they
  3118.     fit  within the    right margin as    closely    as possible.
  3119.     Therefore, it is not necessary for the ADL  program-
  3120.     mer  to     take  great care in formatting    the messages
  3121.     passed to $say.     If the    programmer desires that     the
  3122.     current     line  be  terminated, and output start    on a
  3123.     new line, the  character  sequence  "\n"  should  be
  3124.     embedded  in  the  string.   Note  that    each str may
  3125.     actually be an expression such    as  ($name  foo)  or
  3126.     ($num @Score).
  3127.  
  3128.     Example:
  3129.              ($say "Hi!     My name is " @MyName "! How are you today?\n")
  3130.              Note that MyName is assumed to contain a string ID.
  3131.  
  3132.  
  3133.  
  3134. $arg    ( $arg num ) ->    Returns    the numth  argument  of     the
  3135.     current     routine.   It is basically the    same as    %num
  3136.     except that in    this  case  num     may  be  a  numeric
  3137.     expression,  not  just a numeric constant.  ($arg 0)
  3138.     returns    the number of arguments    passed to this invo-
  3139.     cation of the current routine.
  3140.  
  3141.     Example:
  3142.              { Print all of the    arguments to this routine }
  3143.              ($setg i 1)
  3144.              (WHILE ($le @i %0)    DO
  3145.                  ($say "Arg    " @i " = " ($arg @i) "\n")
  3146.              )
  3147.  
  3148.  
  3149.  
  3150. $exit    ( $exit    code ) -> Doesn't return to the    current    rou-
  3151.     tine.    $exit  terminates  execution  of the current
  3152.     phase.    If code    is 0, control  passes  to  the    next
  3153.     phase.     If  code is 1,    control    passes to the outer-
  3154.     most loop.  If code is 2, control passes to the     top
  3155.     of  the     Dobj loop.  If    code is    3, control passes to
  3156.     the parser which attempts to complete a    partial    sen-
  3157.     tence.     See the diagram in Chapter 4 for a complete
  3158.     definition.
  3159.  
  3160.     Example:
  3161.              take(PREACT) =
  3162.                  (IF ($ne ($loc @Dobj) ($loc .ME)) THEN
  3163.  
  3164.  
  3165.  
  3166.         c 1987 Ross    Cunniff    and Tim    Brengle
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                - 47    -
  3173.  
  3174.  
  3175.                      ($say "You    don't see that here!\n")
  3176.                      { Skip the    rest of    the phases }
  3177.                      ($exit 1)
  3178.                  )
  3179.              ;
  3180.              safe(ACTION) =
  3181.                  (IF ($eq @Verb take) THEN
  3182.                      ($say "You    can't budge the    safe.\n")
  3183.                      { Go on to    the rest of the    Dobjs }
  3184.                      ($exit 2)
  3185.                  )
  3186.              ;
  3187.              ball(ACTION) =
  3188.                  (IF ($prop    ball BROKEN) THEN
  3189.                      { Rely on the default verb    ACTION }
  3190.                      ($exit 0)
  3191.                  )
  3192.                  ($say "The    ball bounces nicely.\n")
  3193.              ;
  3194.              NOVERB(PREACT) =
  3195.                  ($say "What do you    want me    to do with the "
  3196.                  ($say ($name @Dobj) "?\n")
  3197.                  { Re-parse    the sentence }
  3198.                  ($exit 3)
  3199.              ;
  3200.  
  3201.  
  3202.  
  3203. $return    ( $return expr ) -> Doesn't return  to    the  current
  3204.     routine.   Evaluates  expr and returns the result to
  3205.     the current routine's  caller.     Note  that  in     the
  3206.     absence     of an explicit    $return, the return value of
  3207.     a routine is the same  as  the    value  of  the    last
  3208.     statement executed.
  3209.  
  3210.     Example:
  3211.              Increment = ($return ($plus %1 1))
  3212.  
  3213.              ($say "Increment( 3 ) = " (Increment 3) "\n")
  3214.                  Increment(    3 ) = 4
  3215.  
  3216.  
  3217.  
  3218. $val    ( $val expr ) ->  Evaluates  expr  and    returns     the
  3219.     result.      Expr    may be a routine call, a constant, a
  3220.     string,    or anything  that  yields  a  16-bit  value.
  3221.     This  routine  is most useful in conditional expres-
  3222.     sions.
  3223.  
  3224.     Example:
  3225.              Signum =
  3226.                  (IF ($lt %1 0) THEN
  3227.                      ($val -1)
  3228.                   ELSEIF ($eq %1 0)    THEN
  3229.  
  3230.  
  3231.  
  3232.         c 1987 Ross    Cunniff    and Tim    Brengle
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                - 48    -
  3239.  
  3240.  
  3241.                      ($val 0)
  3242.                   ELSE
  3243.                      ($val 1)
  3244.                  )
  3245.              ;
  3246.  
  3247.  
  3248.  
  3249. $phase    ( $phase )  ->    Returns     the  number  of  the  phase
  3250.     currently  executing.    This  number is    0 during the
  3251.     START phase, 1 during the Daemon phase,    2 during the
  3252.     Actor ACTION, 3    during the Verb    PREACT,    4 during the
  3253.     Iobj ACTION, 5 during the Dobj ACTION, 6 during     the
  3254.     Verb ACTION, and 7 during the Room ACTION.
  3255.  
  3256.     Example:
  3257.                  (IF ($eq ($phase) 2) THEN
  3258.                      ($say "This is the    Actor ACTION\n")
  3259.                   ELSEIF ($eq ($phase) 4) THEN
  3260.                      ($say "This is the    Iobj ACTION\n")
  3261.                   ELSEIF ($eq ($phase) 5) THEN
  3262.                      ($say "This is the    Dobj ACTION\n")
  3263.                  )
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.         c 1987 Ross    Cunniff    and Tim    Brengle
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.                - 49    -
  3305.  
  3306.  
  3307. 8.  ADL    Program    Structure
  3308.  
  3309.      In    the following extended BNF description of  ADL    pro-
  3310. gram  structure,  terminal symbols are in BOLD UPPERCASE and
  3311. non-terminals in lowercase.  Items enclosed  in     quotes     are
  3312. literal    terminals.
  3313.  
  3314.  
  3315.      adlprog =         stmt *
  3316.  
  3317.      stmt    =         "INCLUDE"         STRING  ";"
  3318.          =         "MESSAGE"         STRING  ";"
  3319.          =         decl
  3320.          =         assign
  3321.  
  3322.      decl    =         "VERB"         ilist
  3323.          =         "ADJEC"         ilist
  3324.          =         "ROUTINE"             ilist
  3325.          =         "ARTICLE"             ilist
  3326.          =         "PREP"         ilist
  3327.          =         "VAR"         vlist
  3328.          =         "NOUN"         nlist
  3329.  
  3330.      assign  =         ID     "="  expr  ";"
  3331.          =         nounp  "("     nprop    ")"  "="  expr    ";"
  3332.          =         VERB  "("    vprop  ")"  "="     routine  ";"
  3333.          =         "("  VAR  [ "+"  const ]  ")"  "="     expr  ";"
  3334.          =         PREP  nounp  PREP    "="  PREP  ";"
  3335.          =         VERB  PREP     "="  VERB  ";"
  3336.  
  3337.      ilist   =         ID     ( ","    ID ) *    ";"
  3338.  
  3339.      vlist   =         vdec  ( ","  vdec ) *  ";"
  3340.  
  3341.      vdec    =         ID     [ "["    const  "]" ]
  3342.  
  3343.      nlist   =         nloc  ( ","  nloc    ) *  ";"
  3344.  
  3345.      nloc    =         nounp  [ "("  nounp  ")" ]
  3346.  
  3347.      nounp   =         [ modif ]    NOUN
  3348.          =         OBJECT
  3349.  
  3350.      modif   =         VERB
  3351.          =         ADJEC
  3352.  
  3353.      vprop   =         "PREACT"
  3354.          =         "ACTION"
  3355.  
  3356.      nprop   =         const
  3357.          =         "LDESC"
  3358.          =         "SDESC"
  3359.          =         "ACTION"
  3360.  
  3361.  
  3362.  
  3363.  
  3364.         c 1987 Ross    Cunniff    and Tim    Brengle
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                - 50    -
  3371.  
  3372.  
  3373.      const   =         NUMBER
  3374.          =         CONST_ID
  3375.  
  3376.      expr    =         const
  3377.          =         STRING
  3378.          =         nounp
  3379.          =         routine
  3380.          =         modif
  3381.          =         ROUTINE
  3382.          =         PREP
  3383.          =         ARTICLE
  3384.          =         VAR
  3385.  
  3386.      routine =         [ locals ]     form +
  3387.  
  3388.      locals  =         "LOCAL"  vlist
  3389.  
  3390.      form    =         "("  ifthen   elseif *   [    else ]    ")"
  3391.          =         "("  "WHILE"  arg    "DO"   form +  ")"
  3392.          =         "("  arg +     ")"
  3393.  
  3394.      ifthen  =         "IF"  arg    "THEN"    form +
  3395.  
  3396.      elseif  =         "ELSEIF"  arg  "THEN"  form +
  3397.  
  3398.      else    =         "ELSE"  form +
  3399.  
  3400.      arg     =         form
  3401.          =         "@"  VAR
  3402.          =         "["  nounp     "]"
  3403.          =         ".ME"
  3404.          =         "%"NUMBER
  3405.          =         const
  3406.          =         STRING
  3407.          =         NOUN
  3408.          =         OBJECT
  3409.          =         ROUTINE
  3410.          =         modif
  3411.          =         PREP
  3412.          =         ARTICLE
  3413.          =         VAR
  3414.          =         vprop
  3415.          =         nprop
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.         c 1987 Ross    Cunniff    and Tim    Brengle
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.                - 51    -
  3437.  
  3438.  
  3439. 9.  ADL    Sentence Structure
  3440.  
  3441.      In    the following extended BNF description of  ADL    sen-
  3442. tences,     terminal  symbols  are     in  BOLD UPPERCASE and    non-
  3443. terminals in lowercase.     A CONJ    is one of the word "and",  a
  3444. comma  (","),  or  the word "but";  a SEP is one of a period
  3445. ("."), the word    "then",    or a  newline.     Comment  statements
  3446. start with "--"    and continue to    the end    of the line.
  3447.  
  3448.  
  3449.      input-line         =    ( sentence  SEP    ) *
  3450.  
  3451.      sentence         =    simple-sent  --    Verb, Iobj, and    Dobj are
  3452.                      --    as you would expect
  3453.              =    noverb-sent  --    Verb = NOVERB;    Iobj and Dobj
  3454.                      --    are as you would expect
  3455.              =    teller-sent  --    Verb = TELLER;    Iobj = object;
  3456.                      --    Dobj = STRING
  3457.  
  3458.      simple-sent     =    verb-phrase  [ dobj-list ]  [ prep  object ]  [    prep ]
  3459.              =    verb-phrase  object  dobj-list    [ prep ]
  3460.  
  3461.      noverb-sent     =    [ dobj-list ]  [ prep  object ]     [ prep    ]
  3462.              =    object    dobj-list  [ prep ]
  3463.  
  3464.      teller-sent     =    object    ","  STRING
  3465.              =    object    ","  VERB  REST-OF-STRING
  3466.  
  3467.      verb-phrase     =    VERB  PREP *
  3468.  
  3469.      dobj-list         =    object    ( CONJ    object ) *
  3470.  
  3471.      object         =    [ ARTICLE ]  modif  NOUN
  3472.              =    [ ARTICLE ]  modif
  3473.              =    [ ARTICLE ]  NOUN
  3474.              =    [ ARTICLE ]  OBJECT
  3475.              =    STRING
  3476.  
  3477.      modif         =    VERB
  3478.              =    ADJEC
  3479.  
  3480.      prep         =    PREP
  3481.              =    PREP  PREP
  3482.              =    PREP  object  PREP
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.         c 1987 Ross    Cunniff    and Tim    Brengle
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.                - 52    -
  3503.  
  3504.  
  3505. 10.  standard.adl
  3506.  
  3507.      Standard.adl  is  a  file    that  contains    many  useful
  3508. default    definitions and    routines.  To use standard.adl,    sim-
  3509. ply put    'INCLUDE "standard.adl"' before     the  rest  of    your
  3510. program.
  3511.  
  3512.      Standard.adl defines six  things:     object     properties,
  3513. constants, global variables, useful words, some    normal verbs
  3514. and their actions, and some utility routines.
  3515.  
  3516. 10.1.  Object properties
  3517.  
  3518.      The  following  object  properties      are    defined      in
  3519.      standard.adl.  The    ADL programmer using standard.adl is
  3520.      advised not to re-use these properties  with  different
  3521.      meanings, as strange and unusual things will happen.
  3522.  
  3523.           SEEN      = 16;
  3524.           OPENS      = 15;
  3525.           LOCKS      = 14;
  3526.           OPENED  = 13;
  3527.           LOCKED  = 12;
  3528.           TRANS      = 11;
  3529.           LIGHT      = 10;
  3530.           FLAME      = 9;
  3531.           NOTAKE  = 8;
  3532.           AllLink = 29;
  3533.           SAVESENT = 28;
  3534.  
  3535.      This leaves boolean properties 1 though 7    and  integer
  3536.      properties     17  through  28  free    for the    programmer's
  3537.      definition    and use.  The above properties are  used  as
  3538.      follows:
  3539.  
  3540.      SEEN       The standard     looking  daemon  sets    this
  3541.            property  of     a room    to TRUE    whenever the
  3542.            player visits the room.
  3543.  
  3544.      OPENS       This    property should    be set to TRUE if it
  3545.            is  possible     to open or close the object
  3546.            (a treasure chest would be an example  of
  3547.            this).
  3548.  
  3549.      LOCKS       This    property should    be set to TRUE if it
  3550.            is  possible    to lock    or unlock the object
  3551.            (a door might be a good example of this).
  3552.  
  3553.      OPENED       This    property  is  set  to  TRUE  if     the
  3554.            object is already opened and    FALSE if the
  3555.            object is  closed.    This  is  meaningful
  3556.            only    if OPENS is TRUE.
  3557.  
  3558.      LOCKED       This    property  is  set  to  TRUE  if     the
  3559.  
  3560.  
  3561.  
  3562.         c 1987 Ross    Cunniff    and Tim    Brengle
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.                - 53    -
  3569.  
  3570.  
  3571.            object  is locked and FALSE if the object
  3572.            is unlocked.     This is meaningful only  if
  3573.            LOCKS is TRUE.
  3574.  
  3575.      TRANS       This    property should    be set    to  TRUE  if
  3576.            the object is transparent (a    glass box or
  3577.            a bottle  would  be    a  good     example  of
  3578.            this).
  3579.  
  3580.      LIGHT       This    property should    be set    to  TRUE  if
  3581.            the    object    gives off light    (in the    case
  3582.            of a    transportable object like  a  flash-
  3583.            light)  or if the object is intrinsically
  3584.            lit (like an    outdoor    location).
  3585.  
  3586.      FLAME       This    property should    be set    to  TRUE  if
  3587.            the object is on fire.
  3588.  
  3589.      NOTAKE       This    property should    be set to TRUE if it
  3590.            is  desired that "take" and "drop" ignore
  3591.            the object when "take all" or "drop    all"
  3592.            are requested.
  3593.  
  3594.      AllLink       This    property is used by the     PREACT     and
  3595.            ACTION  routines  of    the verbs "take" and
  3596.            "drop" and should not be used by anything
  3597.            else.
  3598.  
  3599.      SAVESENT       This    property is used to hold the  start-
  3600.            ing number of a block of six    global vari-
  3601.            ables in which to store  a  sentence     for
  3602.            use with ActAction, below.
  3603.  
  3604.  
  3605. 10.2.  Constants
  3606.  
  3607.      For convenience and readability,  standard.adl  defines
  3608.      the following constants:
  3609.  
  3610.           TRUE    = 1;
  3611.           FALSE    = 0;
  3612.           NULL    = 0;
  3613.  
  3614.  
  3615.      In    addition, the following    constants  are    defined     for
  3616.      use as arguments to the $spec routine:
  3617.  
  3618.           DEBUG    = 1;
  3619.           RESTART = 2;
  3620.           QUIT = 3;
  3621.           SAVE = 4;
  3622.           RESTORE = 5;
  3623.           EXEC = 6;
  3624.           PRESERVE = 7;
  3625.  
  3626.  
  3627.  
  3628.         c 1987 Ross    Cunniff    and Tim    Brengle
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.                - 54    -
  3635.  
  3636.  
  3637.           SCRIPT = 8;
  3638.           HEADER = 9;
  3639.           MARGIN = 10;
  3640.  
  3641.  
  3642.      The following constants are defined for  use  as  argu-
  3643.      ments  to    the  Expect  routine  (described  in section
  3644.      10.6):
  3645.  
  3646.           NO_OBJ = 1;
  3647.           ONE_OBJ = 2;
  3648.           MULT_OBJ = 4;
  3649.           PLAIN_OBJ = 8;
  3650.           STR_OBJ = 16;
  3651.  
  3652.  
  3653.      The  following  global  variables     are   declared      by
  3654.      standard.adl for use by the ADL programmer:
  3655.  
  3656.           Skip,
  3657.           Indent,
  3658.           Dark,
  3659.           MyLoc,
  3660.           Verbose,
  3661.           Scripting,
  3662.           LastVerb,
  3663.           LastNumd,
  3664.           LastDobj,
  3665.           LastPrep,
  3666.           LastIobj;
  3667.  
  3668.      The above globals are used    as follows:
  3669.  
  3670.      Skip       Skip    is used    in preference to  ($exit  1)
  3671.            or  ($exit 2) inside    Object ACTIONs if it
  3672.            is desired that the rest  of     the  Object
  3673.            list     be  processed by the Verb ACTION of
  3674.            "take" or "drop" (see the  discussion  on
  3675.            TakeAct and DropAct below).
  3676.  
  3677.      Indent       Indent should be set    to  TRUE  if  object
  3678.            descriptions     are  to  be indented by two
  3679.            spaces before being printed.
  3680.  
  3681.      Dark       Dark    is TRUE    if  it    is  currently  dark.
  3682.            This     variable  is set by the Looker    rou-
  3683.            tine    if there is no light in    the  current
  3684.            location  of     .ME, and may also be set as
  3685.            the result of some other action.
  3686.  
  3687.      MyLoc       MyLoc is the    location of  the  player  at
  3688.            the    outset    of  the     previous turn.     The
  3689.            routine  Looker  checks  to    see  whether
  3690.            MyLoc  is the same as the location of the
  3691.  
  3692.  
  3693.  
  3694.         c 1987 Ross    Cunniff    and Tim    Brengle
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.                - 55    -
  3701.  
  3702.  
  3703.            player.  If so, the room  description  is
  3704.            printed.   If not, no action    is performed
  3705.            by Looker.  MyLoc is    initialized to -1 to
  3706.            force  the printing of a room description
  3707.            at the beginning of the game.
  3708.  
  3709.      Verbose       Verbose should be  set  to  TRUE  if     the
  3710.            player  wishes that all room    descriptions
  3711.            be verbose ones (i.e.  long    descriptions
  3712.            of  the  room and its contents).  If    Ver-
  3713.            bose    is  false  and    the  room  has    been
  3714.            visited  previously,     a short description
  3715.            will    be printed.
  3716.  
  3717.      Scripting       Scripting is    set to TRUE by the ACTION of
  3718.            the    Verb  "script"    when output is being
  3719.            scripted to a file.    It is  FALSE  other-
  3720.            wise.
  3721.  
  3722.      LastVerb       LastVerb, LastNumd,    LastDobj,  LastPrep,
  3723.            and    LastIobj  contain the values present
  3724.            in the sentence prior to the    current    sen-
  3725.            tence.  These values    are set    in the stan-
  3726.            dard      looking   daemon.    The   routine
  3727.            SaveSentence     is  provided  for this    pur-
  3728.            pose.
  3729.  
  3730.  
  3731. 10.3.  Words
  3732.  
  3733.      The following words are defined to    be a  standard    part
  3734.      of    the ADL    vocabulary:
  3735.  
  3736.      PREP       with, to, into, at, under, from, off, on;
  3737.  
  3738.      in    = into;
  3739.  
  3740.      ARTICLE       the,    a, an;
  3741.  
  3742.      NOUN       all,    it;
  3743.  
  3744.  
  3745. 10.4.  Verbs and their actions
  3746.  
  3747.      Standard.adl declares the following verbs,    and initial-
  3748.      izes  their  PREACT  and  ACTION  routines    to (usually)
  3749.      fairly simply-minded defaults.
  3750.  
  3751.           n,  s,  e,  w,
  3752.           ne, se, nw, sw,
  3753.           up, down,
  3754.           enter, exit,
  3755.           get, put, take, drop,
  3756.           wear,    remove,
  3757.  
  3758.  
  3759.  
  3760.         c 1987 Ross    Cunniff    and Tim    Brengle
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.                - 56    -
  3767.  
  3768.  
  3769.           verbose, terse,
  3770.           open,    close,
  3771.           lock,    unlock,
  3772.           move,    break, rub, touch,
  3773.           throw, read, burn,
  3774.           examine, look, inventory,
  3775.           quit,    restart,
  3776.           save,    restore, script,
  3777.           turn,    douse, light,
  3778.           wait,    again, go;
  3779.  
  3780.  
  3781.      The following verbs have special semantics    and redefin-
  3782.      ition  of    their  PREACT  or  ACTION routines should be
  3783.      avoided:
  3784.  
  3785.      NOVERB       NOVERB (which is predeclared    by  ADL)  is
  3786.            the    verb  returned    by the parser if the
  3787.            player's  sentence  contained  no   verb.
  3788.            Standard.adl     initializes  the  PREACT of
  3789.            NOVERB so that appropriate  requests     for
  3790.            more    information are    generated.
  3791.  
  3792.      put       "Put" transforms itself into    "drop"    then
  3793.            calls the PREACT of "drop".
  3794.  
  3795.      get       "Get" transforms itself into    "take"    then
  3796.            calls the PREACT of "take".
  3797.  
  3798.      take       "Take" determines whether the sentence is
  3799.            one    like "Take all but the sword and the
  3800.            shield".  If    it is then a list of objects
  3801.            is  built  up  which     are then taken.  If
  3802.            not,    the normal semantics apply.  If     the
  3803.            programmer  wants  an  action  to be    per-
  3804.            formed by the "take"    ACTION,    the  routine
  3805.            TakeAct should be defined.
  3806.  
  3807.      drop       "drop" may  be  used     in  sentences    like
  3808.            "Drop  all  but  the     book."     If it is so
  3809.            used, a list    of objects is created  which
  3810.            are    then  dropped.     If  the  programmer
  3811.            wants an action to be  performed  by     the
  3812.            "drop" ACTION, the routine DropAct should
  3813.            be defined.
  3814.  
  3815.      go           If "go" is used in a     sentence  like     "Go
  3816.            north",  the     Verb  is changed to "north"
  3817.            and the Dobj    and Iobj are  set  to  NULL.
  3818.            This     only applies to the direction verbs
  3819.            "north",   "south",      "east",    "west",
  3820.            "northeast",      "southeast",    "northwest",
  3821.            "southwest",    "up", and "down".
  3822.  
  3823.  
  3824.  
  3825.  
  3826.         c 1987 Ross    Cunniff    and Tim    Brengle
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.                - 57    -
  3833.  
  3834.  
  3835.      again       If  the  standard  actor  action  is      in
  3836.            effect,  the     Verb  "again" will never be
  3837.            called or seen by  Objects  since  it  is
  3838.            replaced by the previous sentence.
  3839.  
  3840.      In     addition  to    declaring   the      preceding   verbs,
  3841.      standard.adl declares the following equivalences:
  3842.  
  3843.           g          = again;
  3844.           z          = wait;
  3845.           l          = look;
  3846.           u          = up;
  3847.           d          = down;
  3848.           north          = n;
  3849.           south          = s;
  3850.           east          = e;
  3851.           west          = w;
  3852.           northeast      = ne;
  3853.           northwest      = nw;
  3854.           southeast      = se;
  3855.           southwest      = sw;
  3856.  
  3857.           put on      = wear;
  3858.           take off      = remove;
  3859.           turn on      = light;
  3860.           turn off      = douse;
  3861.  
  3862.  
  3863. 10.5.  Routines
  3864.  
  3865.      Standard.adl declares and defines    the  following    Rou-
  3866.      tines for use by the ADL programmer:
  3867.  
  3868.           StdInit,
  3869.           Reach,
  3870.           See,
  3871.           Lit,
  3872.           Avail,
  3873.           CheckAvail,
  3874.           Expect,
  3875.           Preact,
  3876.           Looker,
  3877.           Prompter,
  3878.           TakeAct,
  3879.           DropAct,
  3880.           ActAction,
  3881.           SaveSentence,
  3882.           Dwimmer;
  3883.  
  3884.      Their use is defined as follows:
  3885.  
  3886.      StdInit       (StdInit actor)  should  be    executed  in
  3887.            START  if the programmer desires that ALL
  3888.            of the default routines be  used.   Actor
  3889.  
  3890.  
  3891.  
  3892.         c 1987 Ross    Cunniff    and Tim    Brengle
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.                - 58    -
  3899.  
  3900.  
  3901.            should   be     the  name  of    the  primary
  3902.            interactive Actor in    the scenario.
  3903.  
  3904.      Reach       (Reach  object  container)  is  TRUE      if
  3905.            object  is  contained in container and if
  3906.            the player can reach    the object.   It  is
  3907.            FALSE  otherwise.   Note  that  this    also
  3908.            checks whether  object  is  contained  in
  3909.            something which is contained    in container
  3910.            and so on.
  3911.  
  3912.      See       (See    object container) is TRUE if  object
  3913.            is  contained in container and the player
  3914.            can see the object.    It is  FALSE  other-
  3915.            wise.  This also checks containers inside
  3916.            containers.
  3917.  
  3918.      Lit       (Lit) is TRUE if  something    is  lighting
  3919.            the    player's  location  and    FALSE other-
  3920.            wise.
  3921.  
  3922.      Avail       (Avail object) is TRUE if the player     can
  3923.            see    object (either in the room or in the
  3924.            player's inventory)    and  can  reach     the
  3925.            object.  It is FALSE    otherwise.
  3926.  
  3927.      CheckAvail       (CheckAvail)    checks to  see    whether     the
  3928.            Dobj     and  Iobj  typed  by the player are
  3929.            available.  If not, an  appropriate    mes-
  3930.            sage     is  printed  and  ($exit 1) is    per-
  3931.            formed.
  3932.  
  3933.      Expect       Expect is typically called by the  PREACT
  3934.            of  a Verb.    It looks at the    current    sen-
  3935.            tence to see    whether    it is of  acceptable
  3936.            form.    The     two  parameters  to  Expect
  3937.            define criteria for    acceptability.     The
  3938.            first  parameter  indicates what types of
  3939.            direct objects  are    acceptable  and     the
  3940.            second  indicates  what types of indirect
  3941.            objects are acceptable.   Each  parameter
  3942.            consists  of     one  or  more of the Expect
  3943.            flags $or'd together.   The    flag  NO_OBJ
  3944.            indicates  that  it is acceptable that no
  3945.            object  be  present;      ONE_OBJ  indicates
  3946.            that     it is acceptable that one object be
  3947.            present;  MULT_OBJ indicates    that  it  is
  3948.            acceptable    that   multiple     objects  be
  3949.            present;  STR_OBJ indicates that it's  OK
  3950.            for    the  object(s)    to  be    strings; and
  3951.            PLAIN_OBJ indicates that it's OK for     the
  3952.            object(s) to    be normal ADL objects.
  3953.  
  3954.            Example:
  3955.  
  3956.  
  3957.  
  3958.         c 1987 Ross    Cunniff    and Tim    Brengle
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.                - 59    -
  3965.  
  3966.  
  3967.                 { "take" needs 1 to N Dobjs and    0 or 1 Iobjs }
  3968.                 take(PREACT) =
  3969.                     (Expect    ($or MULT_OBJ PLAIN_OBJ)
  3970.                         ($or NO_OBJ ONE_OBJ PLAIN_OBJ))
  3971.                 ;
  3972.                 { "quit" can accept no objects }
  3973.                 quit(PREACT) =
  3974.                     (Expect     NO_OBJ     NO_OBJ)
  3975.                 ;
  3976.                 { "unlock" needs exactly one Dobj and Iobj }
  3977.                 unlock(PREACT) =
  3978.                     (Expect    ($or  ONE_OBJ  PLAIN_OBJ)
  3979.                         ($or  ONE_OBJ  PLAIN_OBJ) )
  3980.                 ;
  3981.                 { "say"    needs a    string to say and possibly
  3982.                   someone to whom to say it }
  3983.                 say(PREACT) =
  3984.                     (Expect    ($or ONE_OBJ STR_OBJ)
  3985.                         ($or NO_OBJ ONE_OBJ PLAIN_OBJ))
  3986.                 ;
  3987.  
  3988.  
  3989.  
  3990.      Preact       Preact is the standard PREACT for  Verbs.
  3991.            It  checks  to make sure that exactly one
  3992.            plain Direct    Object was  typed  and    that
  3993.            the    Indirect Object    is not a string.  It
  3994.            also    checks to see  whether    all  of     the
  3995.            named objects are available.
  3996.  
  3997.      Looker       Looker is the  standard  looking  daemon.
  3998.            It is intended to be    executed every turn.
  3999.            To enable this, either of the  statements
  4000.            ($sdem Looker) or (StdInit actor) must be
  4001.            executed (where  actor)  is    the  primary
  4002.            actor).
  4003.  
  4004.      Prompter       Prompter is the standard  prompting    rou-
  4005.            tine.   To  use  it,    either of the state-
  4006.            ments  ($prompt  Prompter)  or   (StdInit
  4007.            actor) must be executed.
  4008.  
  4009.      ActAction       ActAction is    the standard  Actor  action.
  4010.            It checks to    see whether the    Verb "again"
  4011.            or the Object "it" was used and  modifies
  4012.            the    sentences appropriately.  To use it,
  4013.            either  of  the  statements    ($setp     .ME
  4014.            ACTION ActAction) or    (StdInit actor)    must
  4015.            be executed.
  4016.  
  4017.      TakeAct       TakeAct is called by    the  default  action
  4018.            routine  of    the  Verb  "take"  after the
  4019.            ACTION routines  of    all  of     the  Direct
  4020.            Objects have    been executed.
  4021.  
  4022.  
  4023.  
  4024.         c 1987 Ross    Cunniff    and Tim    Brengle
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.                - 60    -
  4031.  
  4032.  
  4033.      DropAct       DropAct is  similar    to  TakeAct,  except
  4034.            that     it  is    called by the ACTION routine
  4035.            of "drop".
  4036.  
  4037.      SaveSentence  SaveSentence    should be called by the     ADL
  4038.            programmer if it is desired that the    Verb
  4039.            "again" and the Object "it"    work  as  in
  4040.            ActAction  above.   Looker calls SaveSen-
  4041.            tence every turn.
  4042.  
  4043.      Dwimmer       Dwimmer is the standard DWIMming routine.
  4044.            It  checks  to  see    whether    an ambiguous
  4045.            object could     possibly  be  the  one     the
  4046.            player  meant.   To    use Dwimmer, include
  4047.            the    statement  (IF    (Dwimmer  %1)    THEN
  4048.            ($return 1))    in DWIMI and/or    DWIMD.
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.         c 1987 Ross    Cunniff    and Tim    Brengle
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.                - 61    -
  4097.  
  4098.  
  4099. Appendix 1 - A Tiny Dungeon
  4100.  
  4101.      The following dungeon is a    tiny but complete  scenario.
  4102. It  demonstrates  the  use of $hit and $miss, as well as the
  4103. use of some of the features of standard.adl.
  4104.  
  4105.  
  4106.      INCLUDE "standard.adl";
  4107.  
  4108.      NOUN startrm, brightroom;             { Locations in the    dungeon    }
  4109.      startrm(LIGHT) = TRUE;         brightroom(LIGHT) = TRUE;
  4110.      cg    = ($say    "You can't go that way.\n");
  4111.  
  4112.      startrm(LDESC) =
  4113.          ($say "You    are in a small but comfortable room.  You hardly "
  4114.            "want to leave, but there is    a door leading east, if    "
  4115.            "you    insist.\n")
  4116.      ;
  4117.      startrm (SDESC) = ($say "Comfortable room.\n");
  4118.      startrm(ACTION) =
  4119.          ($miss cg cg 0 cg 0 0 0 0 0 0)
  4120.          ($hit .ME 0 0 brightroom 0    0 0 0 0    0 0)
  4121.      ;
  4122.      brightroom(LDESC) =
  4123.          ($say "You    are in a brightly lit room.  The walls sparkle "
  4124.            "with scintillating lights.    There is a darker room "
  4125.            "to the west.\n")
  4126.      ;
  4127.      brightroom(SDESC) = ($say "Bright room.\n");
  4128.      brightroom(ACTION)    =
  4129.          ($miss cg cg cg 0 0 0 0 0 0 0)
  4130.          ($hit .ME 0 0 0 startrm 0 0 0 0 0 0)
  4131.      ;
  4132.      ADJEC red,    blue;
  4133.      NOUN red pillow(startrm), blue pillow(startrm);
  4134.  
  4135.      red pillow(LDESC) = ($say "There is a red pillow here.\n");
  4136.      red pillow(SDESC) = ($say "A red pillow");
  4137.  
  4138.      blue pillow(LDESC)    = ($say    "There is a blue pillow    here.\n");
  4139.      blue pillow(SDESC)    = ($say    "A blue    pillow");
  4140.  
  4141.      NOUN platinum(brightroom);             bar = platinum;
  4142.      platinum(LDESC) = ($say "There is a bar of    platinum here!\n");
  4143.      platinum(SDESC) = ($say "A    platinum bar");
  4144.      platinum(ACTION) =
  4145.          (IF         ($and ($eq    ($verb)    drop)
  4146.                  ($eq ($loc    .ME) ($loc [red    pillow])))
  4147.          THEN
  4148.              ($say "The    bar falls onto the red pillow, breaking    it! "
  4149.                "The    symbolism impresses itself upon    you, and "
  4150.                "you    go back    to work    instead    of playing these "
  4151.                "silly games!\n")
  4152.              ($spec 3)
  4153.  
  4154.  
  4155.  
  4156.         c 1987 Ross    Cunniff    and Tim    Brengle
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.                - 62    -
  4163.  
  4164.  
  4165.          )
  4166.      ;
  4167.      NOUN SELF(startrm);         SELF(NOTAKE) = TRUE;
  4168.  
  4169.      START = ($prompt Prompter)
  4170.          ($sdem Looker)
  4171.          ($actor SELF 0 1 0)
  4172.          ($setv n s    e w 0 0    0 0 0 0)
  4173.      ;
  4174.      DWIMD = ($return (DWIM %1));
  4175.      DWIMI = (DWIM %1);         { This result will    be returned by default }
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.         c 1987 Ross    Cunniff    and Tim    Brengle
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.                - 63    -
  4229.  
  4230.  
  4231. Appendix 2 - A scenario    with multiple Actors
  4232.  
  4233.      The following ADL program demonstrates both the use  of
  4234. the  standard  package and the use of multiple actors.    This
  4235. is the scenario    which generated    the script at the  beginning
  4236. of this    document.
  4237.  
  4238.  
  4239. INCLUDE    "standard.adl";        { Include the standard package }
  4240.  
  4241.  
  4242. { The following    are Object properties }
  4243.  
  4244. BROKEN    =  1;        { Is the robot damaged?    }
  4245. TOLD    =  2;        { Have I told the robot    something? }
  4246. BSTATE    = 17;        { State    of the button }
  4247.     B_OFF    =  0;    { Button is off    }
  4248.     B_FLASH    =  1;    { Button is flashing }
  4249.     B_LIT    =  2;    { Button is lit    }
  4250.  
  4251.  
  4252. { Global variables }
  4253.  
  4254. VAR
  4255.     RobSave[ 6 ],    { Saved    sentence for the robot }
  4256.     Score;        { Current score    }
  4257.  
  4258.  
  4259. { Utility routines }
  4260.  
  4261. ROUTINE
  4262.     NoGo,    Sayer,    Myself,    Lifter,
  4263.     DoorCk,    TrapCk,    RobMov,    BlueCk,
  4264.     Header,    Die,    Skore,    RobEntr,
  4265.     HatchSD;
  4266.  
  4267.  
  4268. { Locations in the dungeon }
  4269.  
  4270. NOUN
  4271.     Redrm,        Bluerm,
  4272.     Greenrm,    Cellar,
  4273.     Endrm;
  4274.  
  4275.  
  4276. { Immovable objects }
  4277.  
  4278. NOUN
  4279.     button(    Bluerm ),
  4280.     door( Cellar ),
  4281.     hatch( Bluerm );
  4282.  
  4283.  
  4284. { Objects which    may become actors }
  4285.  
  4286.  
  4287.  
  4288.         c 1987 Ross    Cunniff    and Tim    Brengle
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.                - 64    -
  4295.  
  4296.  
  4297. NOUN
  4298.     me( Redrm ),
  4299.     robot( Greenrm );
  4300.  
  4301. me( NOTAKE ) = TRUE;
  4302.  
  4303.  
  4304. { Room descriptions }
  4305.  
  4306. Redrm( LDESC ) =
  4307.     ($say
  4308. "You are in a large room which is illuminated by a bright
  4309. red glow.  Exits lie to    the east and south.\n"
  4310.     )
  4311. ;
  4312. Redrm( SDESC ) = ($return (Header "Red room" %0));
  4313. Redrm( LIGHT ) = TRUE;
  4314.  
  4315.  
  4316. Greenrm( LDESC ) =
  4317.     ($say
  4318. "You are in a smallish room which is illuminated by a pleasant
  4319. green glow.  The only exit is to the west.\n"
  4320.     )
  4321. ;
  4322. Greenrm( SDESC ) = ($return (Header "Green room" %0));
  4323. Greenrm( LIGHT ) = TRUE;
  4324.  
  4325.  
  4326. Bluerm(    LDESC )    =
  4327.     ($say
  4328. "You are in a tiny room    which is barely    illuminated by a
  4329. dim blue glow.    There is an exit to the    north,"
  4330.     )
  4331.     (IF ($eq ($prop    button BSTATE) B_LIT) THEN
  4332.         ($say
  4333. " and most of the floor    has tilted up to reveal    a hatch    leading
  4334. down into blackness.  A    button on the wall is glowing brightly."
  4335.         )
  4336.      ELSE
  4337.         ($say "    and you    seem to    make out something on the floor.")
  4338.         (IF ($prop button BSTATE) THEN
  4339.             ($say "     A button on the wall is flashing urgently.")
  4340.          ELSE
  4341.             ($say "     There is a button on the wall.")
  4342.         )
  4343.     )
  4344.     ($say
  4345. "  Above the button is a sign that reads:\n\n"
  4346. "        DANGER!\n\n"
  4347. "         HIGH VOLTAGE!\n\n"
  4348.     )
  4349. ;
  4350. Bluerm(    SDESC )    =
  4351.  
  4352.  
  4353.  
  4354.         c 1987 Ross    Cunniff    and Tim    Brengle
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.                - 65    -
  4361.  
  4362.  
  4363.     (IF %0 THEN ($return "Blue room"))
  4364.     ($say "Blue room.\n")
  4365. ;
  4366. Bluerm(    LIGHT )    = TRUE;
  4367.  
  4368.  
  4369. Cellar(    LDESC )    =
  4370.     ($say
  4371. "You are in the    cellar.     Far above you can be seen a dim
  4372. blue light."
  4373.     )
  4374.     (IF ($prop door    OPENED)    THEN
  4375.         ($say
  4376. "  An open door    leads to the north.\n"
  4377.         )
  4378.      ELSE
  4379.         ($say
  4380. "  You can barely see the outline of a door to the north.\n"
  4381.         )
  4382.     )
  4383. ;
  4384. Cellar(    SDESC )    =
  4385.     ($return (Header "Cellar" %0))
  4386. ;
  4387. Cellar(    LIGHT )    = TRUE;
  4388.  
  4389.  
  4390. Endrm( LDESC ) =
  4391.     ($say
  4392. "You exit from the dark    cellar into a land filled with singing birds,
  4393. blooming flowers, flowing streams, and bright blue skies.  In other words,
  4394. you have finished this game!\n"
  4395.     )
  4396.     ($setg Score ($plus @Score 25))
  4397.     (Skore)
  4398.     ($spec 3)
  4399. ;
  4400. Endrm( LIGHT ) = TRUE;
  4401.  
  4402.  
  4403. { Verbs    }
  4404.  
  4405. VERB
  4406.     score,
  4407.     push,
  4408.     shout;
  4409.  
  4410. tell = TELLER;
  4411. say = tell;
  4412. press =    push;
  4413. feel = touch;
  4414. yell = shout;
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.         c 1987 Ross    Cunniff    and Tim    Brengle
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.                - 66    -
  4427.  
  4428.  
  4429. { Verb routines    }
  4430.  
  4431. tell( PREACT ) =
  4432.     (IF ($ne @Iobj robot) THEN
  4433.         { The only logical thing to talk to is the robot }
  4434.         (Sayer
  4435. "Talking to yourself is    said to    be a sign of impending insanity"
  4436.         )
  4437.      ELSEIF    ($ge @Dobj 0) THEN
  4438.         { You must say strings }
  4439.         (Sayer
  4440. "You must put what you want to say in quotes"
  4441.         )
  4442.      ELSEIF    ($ne ($loc robot) ($loc    me)) THEN
  4443.         { The robot must be in the same    place as the player }
  4444.         (IF (Myself) THEN
  4445.             ($say "You don't see the robot here.\n")
  4446.         )
  4447.      ELSE
  4448.         { Everything is    OK.  Add 25 points to the score    }
  4449.         (IF ($not ($prop robot TOLD)) THEN
  4450.             ($setg Score ($plus @Score 25))
  4451.             ($setp robot TOLD TRUE)
  4452.         )
  4453.         ($exit 0)
  4454.     )
  4455.     ($exit 1)
  4456. ;
  4457. tell( ACTION ) =
  4458.     { Tell the player that we heard    him }
  4459.     ($say "\"Sure thing, Boss.\"\n")
  4460.  
  4461.     { Delete the old action    }
  4462.     ($delact robot)
  4463.  
  4464.     { Add the new action - a non-interactive actor }
  4465.     ($actor    robot @Dobj FALSE)
  4466. ;
  4467.  
  4468.  
  4469. shout( PREACT )    =
  4470.     (IF    ($and @Iobj ($ne @Iobj robot)) THEN
  4471.         { Shouting at things other than    the robot }
  4472.         ($say "AAARRRGGGHHH!\n")
  4473.      ELSEIF    ($ge @Dobj 0) THEN
  4474.         { Shouting things other    than strings }
  4475.         ($say "EEEYYYAAAHHH!\n")
  4476.      ELSEIF    ($prop robot BROKEN) THEN
  4477.         ($say "There is    no response.\n")
  4478.      ELSE
  4479.         { Shouting at the robot    - same as telling the robot }
  4480.         (IF ($not ($prop robot TOLD)) THEN
  4481.             ($setg Score ($plus @Score 25))
  4482.             ($setp robot TOLD TRUE)
  4483.  
  4484.  
  4485.  
  4486.         c 1987 Ross    Cunniff    and Tim    Brengle
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.                - 67    -
  4493.  
  4494.  
  4495.         )
  4496.         ($exit 0)
  4497.     )
  4498.     ($exit 1)
  4499. ;
  4500. shout( ACTION )    =
  4501.     { Tell the player we heard him }
  4502.     (IF ($ne ($loc robot) ($loc me)) THEN
  4503.         ($say "In the distance you hear    the words, ")
  4504.     )
  4505.     ($say "\"Sure thing, Boss\"\n")
  4506.  
  4507.     { Delete the old robot action }
  4508.     ($delact robot)
  4509.  
  4510.     { Add the new robot action }
  4511.     ($actor    robot @Dobj FALSE)
  4512. ;
  4513.  
  4514.  
  4515. push( PREACT ) =
  4516.     { Expect a plain direct    object }
  4517.     (Expect    ($or ONE_OBJ PLAIN_OBJ)    NO_OBJ)
  4518.     (CheckAvail)
  4519. ;
  4520. push( ACTION ) =
  4521.     (Sayer "That doesn't seem to do    anything")
  4522.     ($exit 1)
  4523. ;
  4524.  
  4525.  
  4526. score(PREACT) =
  4527.     { Score    can accept no objects }
  4528.     (Expect    NO_OBJ NO_OBJ)
  4529.     (Skore)
  4530.     ($exit 1)
  4531. ;
  4532.  
  4533.  
  4534. { Object properties }
  4535.  
  4536. button(    SDESC )    =
  4537.     (IF ($eq ($prop    button BSTATE) B_OFF) THEN
  4538.         ($say "a button")
  4539.      ELSEIF    ($eq ($prop button BSTATE) B_FLASH) THEN
  4540.         ($say "an urgently flashing button")
  4541.      ELSE
  4542.         ($say "a brightly lit button")
  4543.     )
  4544. ;
  4545. button(    ACTION ) =
  4546.     (IF ($and    (Myself)
  4547.             ($or    ($eq @Verb push)
  4548.                 ($eq @Verb take)
  4549.  
  4550.  
  4551.  
  4552.         c 1987 Ross    Cunniff    and Tim    Brengle
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.                - 68    -
  4559.  
  4560.  
  4561.                 ($eq @Verb touch)
  4562.             )
  4563.         )
  4564.      THEN
  4565.         { The player tried to do something with    the button }
  4566.         ($say
  4567. "As you    reach for the button, a    10,000,000 volt    bolt of    lightning
  4568. arcs toward your finger, disintegrating    you upon impact.\n"
  4569.         )
  4570.         (Die)
  4571.      ELSEIF    ($and ($eq @Verb push) ($eq ($prop button BSTATE) B_OFF)) THEN
  4572.         { The robot pushed the button }
  4573.         ($setp button BSTATE B_FLASH)
  4574.         ($setg Score ($plus @Score 50))
  4575.         ($sfus me Lifter 4)
  4576.         ($exit 1)
  4577.      ELSEIF    ($eq @Verb take) THEN
  4578.         { Can't    take the button    }
  4579.         ($setg Skip TRUE)
  4580.     )
  4581. ;
  4582.  
  4583.  
  4584. SimpleRobot = "I am just a simple robot";
  4585. robot( LDESC ) = ($say "There is a robot here.\n");
  4586. robot( SDESC ) = ($say "a robot");
  4587. robot( ACTION )    =
  4588.     (IF (Myself) THEN
  4589.         { I'm doing something with the robot }
  4590.         (IF ($eq @Verb tell) THEN
  4591.             (IF ($prop robot BROKEN) THEN
  4592.                 ($say "There is    no response.\n")
  4593.                 ($exit 1)
  4594.             )
  4595.          ELSEIF    ($eq @Verb take) THEN
  4596.             ($say "The robot weighs    at least 500 pounds!\n")
  4597.             ($exit 1)
  4598.         )
  4599.      ELSEIF    ($eq ($phase) 2) THEN
  4600.         { This is being    called as the Actor ACTION }
  4601.         (ActAction)
  4602.         (IF ($and    ($ne @Verb push)
  4603.                 ($ne @Verb go)
  4604.                 ($ne @Verb wait)
  4605.                 ($ne @Verb take)
  4606.                 ($or ($lt @Verb    north) ($gt @Verb down)))
  4607.          THEN
  4608.             { The robot has    a VERY simple vocabulary }
  4609.             (Sayer SimpleRobot)
  4610.             ($delact robot)
  4611.             ($exit 1)
  4612.         )
  4613.      ELSEIF    ($eq @Verb take) THEN
  4614.         { The robot is trying to take itself }
  4615.  
  4616.  
  4617.  
  4618.         c 1987 Ross    Cunniff    and Tim    Brengle
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.                - 69    -
  4625.  
  4626.  
  4627.         (Sayer "Mmmph!    Akkk!!    GGGGRR!!  No can do.  Sorry")
  4628.         ($setg Skip TRUE)
  4629.      ELSE
  4630.         { The robot is doing something to itself }
  4631.         (Sayer SimpleRobot)
  4632.         ($delact robot)
  4633.         ($exit 1)
  4634.     )
  4635. ;
  4636. robot( SAVESENT    ) = RobSave;
  4637.  
  4638.  
  4639.  
  4640. {    We break me( ACTION ) out into a named routine because
  4641.     StdInit    overwrites that    property and we    need to    restore    it    }
  4642.  
  4643. MeAct =
  4644.     (IF ($eq ($phase) 2) THEN
  4645.         { This is the Actor ACTION - call standard's actor action }
  4646.         (ActAction)
  4647.      ELSEIF    ($eq @Verb take) THEN
  4648.         (Sayer "I thought you would never ask")
  4649.         ($setg Skip TRUE)
  4650.     )
  4651. ;
  4652.  
  4653.  
  4654. {    We break hatch(    SDESC )    out into a named routine because
  4655.     the hatch isn't    visible    until after Lifter has executed        }
  4656.  
  4657. HatchSD    = ($say    "an open hatch");
  4658. HatchMSG = "The    hatch doesn't budge";
  4659. hatch( ACTION )    =
  4660.     (IF ($eq @Verb take) THEN
  4661.         { Can't    take the hatch }
  4662.         (Sayer HatchMSG)
  4663.         ($setg Skip TRUE)
  4664.      ELSEIF    ($or ($eq @Verb    open) ($eq @Verb push))    THEN
  4665.         { Can't    open or    push it, either    }
  4666.         (Sayer HatchMSG)
  4667.         ($exit 1)
  4668.     )
  4669. ;
  4670. hatch( OPENS ) = TRUE;
  4671. hatch( NOTAKE )    = TRUE;
  4672.  
  4673.  
  4674. door( SDESC ) =    ($say "a door");
  4675. door( ACTION ) =
  4676.     (IF ($eq @Verb take) THEN
  4677.         ($say "You can't take a    door!\n")
  4678.         ($setg Skip TRUE)
  4679.     )
  4680. ;
  4681.  
  4682.  
  4683.  
  4684.         c 1987 Ross    Cunniff    and Tim    Brengle
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.                - 70    -
  4691.  
  4692.  
  4693. door( OPENS ) =    TRUE;
  4694.  
  4695.  
  4696. {    Transition routines.  Note that    RobMov is used in $miss.
  4697.     This produces the 'The robot exits to the <direction>
  4698.     messages.  The calls to    RobEntr    produce    the messages like
  4699.     'The robot enters from the <direction>.        }
  4700.  
  4701. Bluerm(    ACTION ) =
  4702.     ($miss RobMov NoGo NoGo    NoGo NoGo TrapCk 0 0 0 0)
  4703.     ($hit .ME Redrm    0 0 0 0    Cellar 0 0 0 0)
  4704.     (RobEntr)
  4705. ;
  4706.  
  4707.  
  4708. Redrm( ACTION )    =
  4709.     ($miss NoGo BlueCk RobMov NoGo NoGo NoGo 0 0 0 0)
  4710.     ($hit .ME 0 Bluerm Greenrm 0 0 0 0 0 0 0)
  4711.     (RobEntr)
  4712. ;
  4713.  
  4714.  
  4715. Greenrm( ACTION    ) =
  4716.     ($miss NoGo NoGo NoGo RobMov NoGo NoGo 0 0 0 0)
  4717.     ($hit .ME 0 0 0    Redrm 0    0 0 0 0    0)
  4718.     (RobEntr)
  4719. ;
  4720.  
  4721.  
  4722. Cellar(    ACTION ) =
  4723.     ($miss DoorCk NoGo NoGo    NoGo BlueCk NoGo 0 0 0 0)
  4724.     ($hit .ME Endrm    0 0 0 Bluerm 0 0 0 0 0)
  4725.     (RobEntr)
  4726. ;
  4727.  
  4728.  
  4729. { Routines }
  4730.  
  4731. { (Myself) - returns 1 if "me" is the current actor; 0 otherwise }
  4732. Myself =
  4733.     ($return ($eq .ME me))
  4734. ;
  4735.  
  4736.  
  4737. {    (Sayer str) - Says a string with appropriate quoting, depending
  4738.     on whether the robot or    the player is doing the    saying.        }
  4739. Sayer =
  4740.     (IF (Myself) THEN
  4741.         ($say %1 ".\n")
  4742.      ELSEIF    ($eq ($loc robot) ($loc    me)) THEN
  4743.         ($say "\"" %1 ", Boss.\"\n")
  4744.      ELSE
  4745.         ($say "You hear    a muffled voice    in the distance.\n")
  4746.     )
  4747.  
  4748.  
  4749.  
  4750.         c 1987 Ross    Cunniff    and Tim    Brengle
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.                - 71    -
  4757.  
  4758.  
  4759. ;
  4760.  
  4761.  
  4762. {    (NoGo) - "You can't go that way"    }
  4763. NoGo =
  4764.     (Sayer "You can't go that way")
  4765.     ($exit 1)
  4766. ;
  4767.  
  4768.  
  4769. {    (Header    str arg0) - To accomplish the printing of header lines,
  4770.     each location SDESC need to return a string if a parameter is
  4771.     passed to it.  By doing    ($return (Header <sdesc> %0)), we can
  4772.     centralize the saying/returning    decision.    }
  4773. Header =
  4774.     (IF ($not %2) THEN
  4775.         ($say %1 ".\n")
  4776.     )
  4777.     ($return %1)
  4778. ;
  4779.  
  4780.  
  4781. RobMov =
  4782.     (IF ($and ($not    (Myself)) ($eq ($loc robot) ($loc me)))    THEN
  4783.         ($say
  4784.             "The robot exits to the    "
  4785.             (IF ($eq @Verb e) THEN
  4786.                 ($val "east")
  4787.              ELSEIF    ($eq @Verb w) THEN
  4788.                 ($val "west")
  4789.              ELSEIF    ($eq @Verb s) THEN
  4790.                 ($val "south")
  4791.              { The robot can't be seen leaving to the north    }
  4792.             )
  4793.             ".\n"
  4794.         )
  4795.     )
  4796. ;
  4797.  
  4798.  
  4799. RobEntr    =
  4800.     (IF ($and ($not    (Myself)) ($eq ($loc robot ) ($loc me))) THEN
  4801.         ($say
  4802.             (IF ($eq @Verb north) THEN
  4803.                 ($val "The robot enters    from the south.\n")
  4804.              ELSEIF    ($eq @Verb east) THEN
  4805.                 ($val "The robot enters    from the west.\n")
  4806.              ELSEIF    ($eq @Verb west) THEN
  4807.                 ($val "The robot enters    from the east.\n")
  4808.              { The robot can't enter from the north    in
  4809.                this    scenario }
  4810.             )
  4811.         )
  4812.     )
  4813.  
  4814.  
  4815.  
  4816.         c 1987 Ross    Cunniff    and Tim    Brengle
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.                - 72    -
  4823.  
  4824.  
  4825. ;
  4826.  
  4827.  
  4828. DoorCk =
  4829.     (IF ($not ($prop door OPENED)) THEN
  4830.         ($say "The door    seems to be closed.\n")
  4831.         ($exit 1)
  4832.     )
  4833. ;
  4834.  
  4835.  
  4836. TrapCk =
  4837.     (IF ($ne ($prop    button BSTATE) B_LIT) THEN
  4838.         (NoGo)
  4839.     )
  4840. ;
  4841.  
  4842.  
  4843. {    (BlueCk) - make    sure that only one actor is in the blue    room
  4844.     at one time.    }
  4845. BlueCk =
  4846.     (IF ($or ($eq ($loc me)    Bluerm)    ($eq ($loc robot) Bluerm)) THEN
  4847.         (IF (Myself) THEN
  4848.             ($say
  4849. "The room is too small for both    you and    the robot to fit.\n"
  4850.             )
  4851.         )
  4852.         ($exit 1)
  4853.      ELSEIF    ($and ($not (Myself)) ($eq ($prop button BSTATE) B_LIT)) THEN
  4854.         (RobMov)
  4855.         ($say "You hear    a loud CRASH! in the distance.\n")
  4856.         ($setg Score ($minus @Score 10))
  4857.         ($setp robot BROKEN TRUE)
  4858.         ($move robot Bluerm)
  4859.         ($delact robot)
  4860.         ($exit 1)
  4861.     )
  4862.     (RobMov)
  4863. ;
  4864.  
  4865.  
  4866. {    (Die) -    kill off the player    }
  4867. Die =
  4868.     ($setg Score ($minus @Score 50))
  4869.     (Skore)
  4870.     ($say "Do you wish to restart the game?    ")
  4871.     (IF ($yorn) THEN
  4872.         ($spec 2)
  4873.      ELSE
  4874.         ($spec 3)
  4875.     )
  4876. ;
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.         c 1987 Ross    Cunniff    and Tim    Brengle
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.                - 73    -
  4889.  
  4890.  
  4891. {    (Lifter) - Lift    the hatch, possibly killing the    robot or
  4892.     the player    }
  4893. Lifter =
  4894.     (IF ($eq ($loc me) Bluerm) THEN
  4895.         ($say
  4896. "All of    a sudden, the floor lifts up, and you are crushed between it
  4897. and the    wall!  "
  4898.         )
  4899.         (Die)
  4900.      ELSE
  4901.         ($say "In the distance,    you hear a loud    CRASH!\n")
  4902.         (IF ($eq ($loc robot) Bluerm) THEN
  4903.             ($setg Score ($minus @Score 10))
  4904.             ($setp robot BROKEN TRUE)
  4905.             ($delact robot)
  4906.         )
  4907.     )
  4908.     ($setp hatch SDESC HatchSD)
  4909.     ($setp button BSTATE B_LIT)
  4910.     ($setp Bluerm SEEN FALSE)
  4911. ;
  4912.  
  4913.  
  4914. {    Prompt - print the status line and a prompt    }
  4915. PROMPT =
  4916.     ($spec 9 (($sdesc ($loc    .ME)) 1) @Score    ($turns))
  4917.     ($say "> ")
  4918. ;
  4919.  
  4920.  
  4921. {    Increment - increment the turn counter    }
  4922. INCREMENT =
  4923.     (IF (Myself) THEN
  4924.         { We only want to increment once per turn }
  4925.         ($incturn)
  4926.      ELSE
  4927.         { We don't want    Looker executing for the robot }
  4928.         ($exit 0)
  4929.     )
  4930. ;
  4931.  
  4932.  
  4933. {    (Skore)    - print    out the    current    score.    }
  4934. Skore =
  4935.     ($say    "You have scored " ($str @Score)
  4936.         " out of a possible 100    in " ($str ($turns)) " moves.\n")
  4937. ;
  4938.  
  4939.  
  4940. {    Dwimming routines    }
  4941. DWIMI =    (Dwimmer %1);
  4942. DWIMD =    (Dwimmer %1);
  4943.  
  4944. START =
  4945.  
  4946.  
  4947.  
  4948.         c 1987 Ross    Cunniff    and Tim    Brengle
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.                - 74    -
  4955.  
  4956.  
  4957.     ($spec MARGIN 69)    { Set the screen to 69 wide }
  4958.     ($sdem INCREMENT)    { Turn counter increment }
  4959.     (StdInit me)        { Initialize standard }
  4960.     ($setp me ACTION MeAct)    { Restore me( ACTION ) }
  4961.     ($setv n s e w u d 0 0 0 0)    { Use our own transition vector    }
  4962.     ($prompt PROMPT)    { and our own prompter }
  4963.     ($setg Indent TRUE)    { Indent the object descriptions }
  4964. ;
  4965.  
  4966. {*** EOF actdemo.adl ***}
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977.  
  4978.  
  4979.  
  4980.  
  4981.  
  4982.  
  4983.  
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.         c 1987 Ross    Cunniff    and Tim    Brengle
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.                - 75    -
  5021.  
  5022.  
  5023. Appendix 3 - Glossary
  5024.  
  5025. Actor        An Actor in ADL    is similar to an Actor in  a
  5026.         play, in that the Actor    has a script to    fol-
  5027.         low (the lines typed  by  the  player),     and
  5028.         there may be more than one Actor acting    at a
  5029.         time.
  5030.  
  5031. Adjective    An adjective  is  a  part  of  speech  which
  5032.         describes  a  noun.   "Red", "green", "big",
  5033.         and "rusty" are    all adjectives.
  5034.  
  5035. Argument    An argument to an ADL routine is one of     the
  5036.         list  of "things" which    the routine was    told
  5037.         to operate on.    For example, in    the  routine
  5038.         call  ($plus 20    30 40) the first argument is
  5039.         20, the    second argument    is 30, and the third
  5040.         argument is 40.
  5041.  
  5042. Article        An article is a    part of    speech    which  often
  5043.         conveys    some sense of "definiteness".  "The"
  5044.         is an article, as are  "a"  and     "an".     ADL
  5045.         ignores     articles  in  player  sentences, so
  5046.         their proper use is of little importance.
  5047.  
  5048. ASCII        ASCII (which stands  for  American  Standard
  5049.         Code  for Information Interchange, as if you
  5050.         really    wanted    to  know)  is  a  method  of
  5051.         representing  characters  (such    as "a",    "b",
  5052.         "9", etc.) as numbers  for  the     purpose  of
  5053.         computer   manipulation.   Thus,  the  ASCII
  5054.         representation of the letter "A" is 65.     The
  5055.         expression  "the ASCII representation of the
  5056.         number 45308" is often    heard.     This  means
  5057.         that  the number 45308 is represented as the
  5058.         ASCII string "45308".  This is slightly    dif-
  5059.         ferent than the    ASCII code of a    character.
  5060.  
  5061. BNF        BNF is a method    of representing     the  syntax
  5062.         of a language in a concise way.     In English,
  5063.         one may    say that "A list is  a    sequence  of
  5064.         things."  In  BNF,  one    may say    that "list =
  5065.         thing *" which means that a list consists of
  5066.         zero  or  more things.    (This is actually an
  5067.         extended form of BNF which is  more  concise
  5068.         than  the  original).    Other things one may
  5069.         say include "foo = bar +" which     means    that
  5070.         foo consists of    one or more bars;  "bletch =
  5071.         [ ack ]    gag" which means that a    bletch is an
  5072.         optional ack followed by a gag.     Parentheses
  5073.         may be used for    grouping; for example "abcbc
  5074.         = a ( b    c ) *" means that an abcbc is an "a"
  5075.         followed by zero or more occurrences of     the
  5076.         two-element list "b c".
  5077.  
  5078.  
  5079.  
  5080.         c 1987 Ross    Cunniff    and Tim    Brengle
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.                - 76    -
  5087.  
  5088.  
  5089. Buffer        See Line Buffer.
  5090.  
  5091. Conjunction    A conjunction is a part    of speech  which  is
  5092.         used   to  join     two  parts  of     a  sentence
  5093.         together.   Conjunctions  include  the    word
  5094.         "and", the word    "but", and the comma ",".
  5095.  
  5096. Container    A container  is     an  object  which  contains
  5097.         another    object,    just as    in real    life.
  5098.  
  5099. Daemon        A daemon is  a    routine     which    is  executed
  5100.         periodically.  For example, in real life Joe
  5101.         Blow  goes  on    a  coffee  break  every      15
  5102.         minutes.   A coffee break could    then be    con-
  5103.         sidered    a daemon  which     executes  every  15
  5104.         minutes     (and  Joe  Blow could be considered
  5105.         lazy).    ADL daemons execute once every turn.
  5106.  
  5107. Direct Object    A direct object    is a part of speech on which
  5108.         the verb is "acting" directly.    For example,
  5109.         in the sentence    "Take  the  food"  the    word
  5110.         "food" is the direct object.  Direct objects
  5111.         may consist of more than one word.
  5112.  
  5113. Fuse        A fuse is similar to a    daemon    except    that
  5114.         instead     of  being executed periodically, it
  5115.         waits a    for some time to pass then  executes
  5116.         exactly     once.     For  example,    in real    life
  5117.         setting    your alarm to go off at    six  o'clock
  5118.         in  the    morning    could be considered activat-
  5119.         ing a fuse.
  5120.  
  5121. Global        See Variable.
  5122.  
  5123. Global Variable    See Variable.
  5124.  
  5125. Implementor    The implementor    is the person who wrote     the
  5126.         ADL  compiler  and ADL interpreter which run
  5127.         on your    computer.  Send    the implementor    lots
  5128.         of praise and/or money.
  5129.  
  5130. Indirect Object    An indirect object is a    part of    speech which
  5131.         is  indirectly    acted upon by the verb.     For
  5132.         example, in the    sentence "Take the rock    from
  5133.         the stream", "stream" is the indirect object
  5134.         as it is not directly affected by  the    verb
  5135.         "take".      Usually an indirect object is    pre-
  5136.         ceded by a preposition.     There is  one    case
  5137.         where  it  is not.  For    example, in the    sen-
  5138.         tence "Give the    frog the  bait"     it  is     the
  5139.         bait  which  is     being given.  This may    seem
  5140.         confusing but if you rewrite the sentence as
  5141.         "Give  the  bait  to the frog" it makes    more
  5142.         sense.
  5143.  
  5144.  
  5145.  
  5146.         c 1987 Ross    Cunniff    and Tim    Brengle
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.                - 77    -
  5153.  
  5154.  
  5155. Line Buffer    A line buffer is an area in  the  memory  of
  5156.         the  computer  where the last line which was
  5157.         typed by a player is  stored.    Words  which
  5158.         are  read  by  the Parser are read from    this
  5159.         buffer,    not directly from the keyboard.
  5160.  
  5161. Local Variable    See Variable.
  5162.  
  5163. Location    The location of    some specified object is the
  5164.         object which contains the specified object.
  5165.  
  5166. Modifier    A modifier is a     part  of  speech  which  is
  5167.         essentially  the  same    as  an    adjective in
  5168.         function.  ADL allows some verbs to  act  as
  5169.         modifiers  in  order  to  better  mimic     the
  5170.         English    language.
  5171.  
  5172. Noun        A noun is a person, place, or thing.  A    desk
  5173.         is  a noun.  America is    a noun.     Fred Rogers
  5174.         is a noun.  "Noun" and "object"    are normally
  5175.         interchangeable      terms.   Usually  however,
  5176.         when a reference is made to something  being
  5177.         a  "noun"  it implies that something is    just
  5178.         one word (as in    "desk"), and not  two  words
  5179.         (as in "blue streak").
  5180.  
  5181. Object        See Noun.
  5182.  
  5183. Parse        Parsing    is the process of breaking  down  an
  5184.         input  string  into  structured     data.     For
  5185.         example, parsing the string "Take the  green
  5186.         brick  and  the     nail  from  the wall" would
  5187.         parse  into  the  verb    "Take",     the  direct
  5188.         objects    "green brick" and "nail", the prepo-
  5189.         sition    "from",     and  the  indirect   object
  5190.         "wall".
  5191.  
  5192. Player        A player is a person who plays a game.    Gen-
  5193.         erally,    a player is associated with an Actor
  5194.         in an ADL scenario.
  5195.  
  5196. Preposition    A preposition is  a  part  of  speech  which
  5197.         often  specifies some location (like "under"
  5198.         or "beside") or    some destination (like    "in"
  5199.         or  "on").  Prepositions are generally found
  5200.         before Indirect    Objects     in  sentences,     but
  5201.         occasionally modify Verbs.
  5202.  
  5203. Prompt        A prompt is some sort of  message  from     the
  5204.         computer  to  a     human    indicating that    some
  5205.         input is expected.
  5206.  
  5207. Programmer    The programmer (in  this  documentation,  at
  5208.         least)    is  the     person    who created the    game
  5209.  
  5210.  
  5211.  
  5212.         c 1987 Ross    Cunniff    and Tim    Brengle
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.                - 78    -
  5219.  
  5220.  
  5221.         scenario which is compiled  and     interpreted
  5222.         by  ADL.  Send the programmer lots of praise
  5223.         and/or money too.
  5224.  
  5225. Room        A room is any object that a player may even-
  5226.         tually enter.
  5227.  
  5228. Routine        A routine is a series of instructions to the
  5229.         computer  telling  it  what  to    say, what to
  5230.         move, what to read, and/or where to go.
  5231.  
  5232. Scenario    A "scenario" is    like a scene in    a play -  it
  5233.         specifies  where  Objects  are located,    what
  5234.         events might occur, who    is present, and    what
  5235.         they  may  do.     A scenario is somewhat    more
  5236.         general    than a scene since scenarios contain
  5237.         rules  for  generating    many possible scenes
  5238.         whereas    scenes are static.
  5239.  
  5240. Separator    A  separator  is  a  part  of  speech  which
  5241.         separates two sentences.  A separator can be
  5242.         a period ".", the word "then", or the end of
  5243.         a line.
  5244.  
  5245. String        A string is a series of    characters (letters,
  5246.         etc.)  surrounded  by quote marks.  "foo bar
  5247.         bletch"    is a string (legal in both the    com-
  5248.         pilation  and  execution  phases of ADL) and
  5249.         'Hi, there!' is    a string (legal    only in     the
  5250.         execution phase    of ADL).
  5251.  
  5252. Stack        A stack    is like    a stack    of dishes:  you     may
  5253.         put  a new dish    on top of the stack (this is
  5254.         known as "pushing") or you may take  a    dish
  5255.         from  the top of the stack (this is known as
  5256.         "popping").  You may not  take    dishes    from
  5257.         the bottom or middle of    the stack; likewise,
  5258.         a computer stack doesn't allow the  deletion
  5259.         of elements in the middle of the stack.
  5260.  
  5261. Syntax        The syntax of a    language is the    set of rules
  5262.         which  say how things may be put together in
  5263.         order  to  make     a  valid  program  in    that
  5264.         language.
  5265.  
  5266. User        See Player.
  5267.  
  5268. Variable    A variable is a    location in the    memory of  a
  5269.         computer  in  which  values  may  be stored,
  5270.         changed, and erased.  Global  variables     (or
  5271.         globals     for  short) are variables which are
  5272.         directly accessible by name to all  routines
  5273.         of  an    ADL  program.    Local  variables (or
  5274.         locals)     are  variables      which      are    only
  5275.  
  5276.  
  5277.  
  5278.         c 1987 Ross    Cunniff    and Tim    Brengle
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.                - 79    -
  5285.  
  5286.  
  5287.         directly  accessible by    the routine in which
  5288.         they are named.     They  are  only  indirectly
  5289.         accessible by other routines.
  5290.  
  5291. Verb        A verb is a part  of  speech  which  implies
  5292.         some action.  "Take", "run", "eat", "sleep",
  5293.         and "hide" are all verbs.
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299.  
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.  
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.         c 1987 Ross    Cunniff    and Tim    Brengle
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.               Table    of Contents
  5354.  
  5355.  
  5356.       1.  Introduction ---------------------------------- 1
  5357.       2.  ADL Data types -------------------------------- 3
  5358.       2.1.    Objects       ---------------------------------- 3
  5359.       2.2.    Verbs       ---------------------------------- 4
  5360.       2.3.    Adjectives ---------------------------------- 5
  5361.       2.4.    Strings       ---------------------------------- 5
  5362.       2.5.    Numbers       ---------------------------------- 5
  5363.       2.6.    Routines   ---------------------------------- 6
  5364.       2.7.    Global Variables ---------------------------- 6
  5365.       2.8.    Local variables    ----------------------------- 6
  5366.       2.9.    Modifiers  ---------------------------------- 6
  5367.       3.  ADL Internal Structures ----------------------- 7
  5368.       3.1.    Actors       ---------------------------------- 7
  5369.       3.2.    Daemons       ---------------------------------- 8
  5370.       3.3.    Fuses       ---------------------------------- 8
  5371.       3.4.    Prompter   ---------------------------------- 8
  5372.       3.5.    Run-Time Macros    ----------------------------- 8
  5373.       4.  Putting It All Together ----------------------- 10
  5374.       4.1.    The Flow of Execution ----------------------- 10
  5375.       4.2.    $exit       ---------------------------------- 13
  5376.       5.  ADL Programs ---------------------------------- 15
  5377.       6.  Routines       ---------------------------------- 20
  5378.       7.  ADL Built-in Routines ------------------------- 23
  5379.       7.1.    Object Routines    ----------------------------- 24
  5380.       7.2.    Verb Routines ------------------------------- 27
  5381.       7.3.    Arithmetic Routines ------------------------- 28
  5382.       7.4.    Boolean    Routines ---------------------------- 29
  5383.       7.5.    Global Value Routines ----------------------- 32
  5384.       7.6.    Transition Routines ------------------------- 34
  5385.       7.7.    String Manipulation Routines ---------------- 35
  5386.       7.8.    Name Routines ------------------------------- 38
  5387.       7.9.    Conversion Routines ------------------------- 39
  5388.       7.10.     Internal Structure Manipulation Routines --- 40
  5389.       7.11.     Special Routines --------------------------- 43
  5390.       7.12.     Miscellaneous Routines    --------------------- 46
  5391.       8.  ADL Program Structure ------------------------- 49
  5392.       9.  ADL Sentence Structure ------------------------ 51
  5393.       10.  standard.adl --------------------------------- 52
  5394.       10.1.     Object    properties -------------------------- 52
  5395.       10.2.     Constants ---------------------------------- 53
  5396.       10.3.     Words       ---------------------------------- 55
  5397.       10.4.     Verbs and their actions -------------------- 55
  5398.       10.5.     Routines  ---------------------------------- 57
  5399.       Appendix 1 - A Tiny Dungeon ----------------------- 61
  5400.       Appendix 2 - A scenario with multiple    Actors ------ 63
  5401.       Appendix 3 - Glossary    ----------------------------- 75
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.         c 1987 Ross    Cunniff    and Tim    Brengle
  5411.  
  5412.  
  5413.